Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to do this in VBA:
Dim cn As New ADODB.Connection Dim sql As String cn.Open "Driver={SQL Server};Server=servername;Database=dbname;Uid=user id;Pwd=password" sql = "INSERT INTO table_name " & _ "(field_1,field_2,field_3,field_4) " & _ "Values ('value1','value2','value3','value4')" cn.Execute sql I get an automation error with the Execute method. However, if I run the query from Query Analyzer it works. So, I'm pretty sure the problem is either I'm not setting up the sql string properly to use with cn.Execute, or I'm using the wrong ADO objects/methods. How do I do this correctly? tod |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Insert subtotal in a query database Excel 2007 | Excel Worksheet Functions | |||
Web Query Error 1004 - Cannot insert columns... | Excel Programming | |||
Modify Recorded SQL Query to "Insert, Delete, Update" | Excel Programming | |||
Range.Insert query | Excel Programming | |||
External web query - insert rows | New Users to Excel |