I am in a corporate environment with IT managed SQL servers. "My" 2014 SQL server is setup and functioning fine.
We want to be able to do a push of data from Excel on a desktop PC to the remote Windows server via VBA. We have some data sources that come in Excel and we already have to open the files and do some Excel cleanup, so it would be convenient to kick off an upload to the SQL server from excel on the desktop vs. pulling them from the server. The files and who updates them may change locations so I don't want a persistent link to the Excel file.
I've found lots of examples on how to do it, and I'm close. but when trying I get this error:
The OLE DB Provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" does not contain the table "WLS$". The table either does not exist or the current user does not have permission on that table.
Some trial and error and it appears "WLS$" is the Excel sheet name. My connection via VBA seems to setup and connect OK.
That code is:
I get the error at that last line.
Figuring the "data source" may be from the perspective of the remote server (is it?), I also tried to point the string that way:
strSQL = " INSERT INTO MYDB.dbo.MYTABLE ([Account]) SELECT [Account] FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0', 'Data Source=\\MyPCName\data\wls12.xlsx;Extended Properties=Excel 12.0')...[WLS$]"
When remoted into the server and logged is as myself, I can access that directory as listed in the string above. But then I get a slightly different error:
The OLE DB Provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error. The provider did not give any information about the error.
I've read every example on the internet I think, tried OpenRowSet instead, no luck. Any suggestions?
We want to be able to do a push of data from Excel on a desktop PC to the remote Windows server via VBA. We have some data sources that come in Excel and we already have to open the files and do some Excel cleanup, so it would be convenient to kick off an upload to the SQL server from excel on the desktop vs. pulling them from the server. The files and who updates them may change locations so I don't want a persistent link to the Excel file.
I've found lots of examples on how to do it, and I'm close. but when trying I get this error:
The OLE DB Provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" does not contain the table "WLS$". The table either does not exist or the current user does not have permission on that table.
Some trial and error and it appears "WLS$" is the Excel sheet name. My connection via VBA seems to setup and connect OK.
That code is:
Code:
SQLServerPath = "SOMEPATH\MYSERVER"
strConn = "Provider=SQLOLEDB;Data Source=" & SQLServerPath & ";Initial Catalog=MYDB;Integrated Security=SSPI;Persist Security Info=True;"
cn.Open strConn
strSQL = " INSERT INTO MYDB.dbo.MYTABLE ([Account]) SELECT [Account] FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0', 'Data Source=C:\data\wls12.xlsx;Extended Properties=Excel 12.0')...[WLS$]"
cn.Execute sSQL
I get the error at that last line.
Figuring the "data source" may be from the perspective of the remote server (is it?), I also tried to point the string that way:
strSQL = " INSERT INTO MYDB.dbo.MYTABLE ([Account]) SELECT [Account] FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0', 'Data Source=\\MyPCName\data\wls12.xlsx;Extended Properties=Excel 12.0')...[WLS$]"
When remoted into the server and logged is as myself, I can access that directory as listed in the string above. But then I get a slightly different error:
The OLE DB Provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error. The provider did not give any information about the error.
I've read every example on the internet I think, tried OpenRowSet instead, no luck. Any suggestions?
Last edited: