View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Vuillermet Jacques Vuillermet Jacques is offline
external usenet poster
 
Posts: 1
Default Excel - VBA - QueryTable error 1004

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:=strConnexi on,
Destination:=ActiveSheet.Range("A1"), Sql:=strSQL)

The strConnexion has been generated by an UDL file.

Thanks.

Jacques.