Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update sql sever

Status
Not open for further replies.

Johnny42

Technical User
Jul 13, 2004
127
CA
Trying to use this:


to update tables in an sql database:

Dim cn As ADODB.Connection
Dim strSQL As String
Dim lngRecsAff As Long
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & ActiveWorkbook.FullName & ";" & _
"Extended Properties=Excel 8.0"

'Import by using Jet Provider.
strSQL = "SELECT * INTO [odbc;Driver={SQL Server};" & _
"Server=<test>;Database=<PerezData>;" & _
"UID=<myname>;PWD=<123456>].[tblSupplier] " & _
"FROM [tblSupplier$]"
Debug.Print strSQL
cn.Execute strSQL, lngRecsAff, adExecuteNoRecords
Debug.Print "Records affected: " & lngRecsAff

cn.Close
Set cn = Nothing

getting error....can anyone help ?
 
getting error
Which error message ? Which line highlighted when in debug mode ?
As we are in the Access VBA forum I assume that ActiveWorkbook.FullName should be qualified with the name of the instantited Excel.Application object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top