Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

VBA Push Excel to SQl Server 2014

$
0
0
Hi guys, Not sure if I picked the correct sub-forum, please point me if not.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 to the 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.I've found lots of examples on how to do it, and I'm close. but when trying I get this error:[i]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.[/i]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 strConnstrSQL = " INSERT INTO MYDB.dbo.MYTABLE ([Account]) SELECT [Account] FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0', 'Data Source=C:\temp\wls12.xlsx;Extended Properties=Excel 12.0')...[WLS$]"cn.Execute sSQL[/code]I get the error after that line.Anyone know how to work out this error and get this working?Thanks,Scott

Viewing all articles
Browse latest Browse all 3145

Trending Articles