I have an MSAccess project with linked SQL tables. I need to import data from an Excel spreadsheet into a SQL table that is linked to my Access project. I have the following code:
Dim cn As ADODB.Connection
Dim strSQL As String
Dim lngRecsAff As Long
Set cn = New ADODB.Connection
cn.Open "Provider=SQLOLEDB;Data Source=PAERSCBBxxxxx;" & _
"Initial Catalog=mydatabasename;UID=;PWD=;"
strSQL = "SELECT * INTO dbo.CC_table_name FROM " & _
"OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0', " & _
"'Data Source=Y:\TECHNOLOGY\xxxxx.xlsx;" & _
"Extended Properties=Excel 8.0')" '''''''...[Customers$]"
cn.Execute strSQL, lngRecsAff, adExecuteNoRecords
When I attempt to run this code, I get the error that the Login failed for my user. But I am using Windows Authentication and thus understand that I don't have to specify a UID. Any assistance on this or if there is another code snippet to import the Excel data, would be appreciated. Thanks.
Dim cn As ADODB.Connection
Dim strSQL As String
Dim lngRecsAff As Long
Set cn = New ADODB.Connection
cn.Open "Provider=SQLOLEDB;Data Source=PAERSCBBxxxxx;" & _
"Initial Catalog=mydatabasename;UID=;PWD=;"
strSQL = "SELECT * INTO dbo.CC_table_name FROM " & _
"OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0', " & _
"'Data Source=Y:\TECHNOLOGY\xxxxx.xlsx;" & _
"Extended Properties=Excel 8.0')" '''''''...[Customers$]"
cn.Execute strSQL, lngRecsAff, adExecuteNoRecords
When I attempt to run this code, I get the error that the Login failed for my user. But I am using Windows Authentication and thus understand that I don't have to specify a UID. Any assistance on this or if there is another code snippet to import the Excel data, would be appreciated. Thanks.