Excel - VBA - QueryTable error 1004

  • Thread starter Vuillermet Jacques
  • Start date
V

Vuillermet Jacques

This code works fine with an Oracle database via ODBC.
But with SQL Server via OLEDB an 1004 error occurs : why ???

["xxx" replaces private data]

Dim qt As Excel.QueryTable
Dim strSQL As String
Dim strConnexion As String

strSQL = "SELECT Id, Libelle FROM Profil"
strConnexion = "Provider=sqloledb;Data Source=xxx.xxx.xxx.xxx;Initial
Catalog=xxx;User Id=xxx;Password=xxx"

Set qt = ActiveSheet.QueryTables.Add(Connection:=strConnexion,
Destination:=ActiveSheet.Range("A1"), Sql:=strSQL)

The strConnexion has been generated by an UDL file.

Thanks.

Jacques.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top