ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel - VBA - QueryTable error 1004 (https://www.excelbanter.com/excel-programming/324401-excel-vba-querytable-error-1004-a.html)

Vuillermet Jacques

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.




All times are GMT +1. The time now is 08:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com