M
mjbigelow
Hello,
I have some VBA that programmatically writes a SQL query. When I paste
the query into Access, it runs just fine. When I try to run it using
ADO via Excel, it gives me the "too many parameters. x expected". The
number that x represents is the number of values that I'm trying to
pass in the values clause of my SQL.
The field names and the order matches up and so do the value/field
types.
Please see the code and the SQL below.
Thanks so much for your help!
Mark
****VBA Code****
Sub Run_Query()
Dim objConn As ADODB.Connection, objRes As ADODB.Recordset
Dim objData As New DataObject
Set objConn = New ADODB.Connection
objConn.Open "st2000"
objData.SetText strSQL
objData.PutInClipboard
Set objRes = objConn.Execute(strSQL)
objConn.Close
Set objRes = Nothing
Set objConn = Nothing
End Sub
***SQL Code***
INSERT INTO TABLE VALUES (62, "1", "2", "3", "4", "5", "6", "", "", "",
"", "", "", "", "", "Other:", "", "", "", "", "", "", "", "", "", "",
"", "Other:", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "");
I have some VBA that programmatically writes a SQL query. When I paste
the query into Access, it runs just fine. When I try to run it using
ADO via Excel, it gives me the "too many parameters. x expected". The
number that x represents is the number of values that I'm trying to
pass in the values clause of my SQL.
The field names and the order matches up and so do the value/field
types.
Please see the code and the SQL below.
Thanks so much for your help!
Mark
****VBA Code****
Sub Run_Query()
Dim objConn As ADODB.Connection, objRes As ADODB.Recordset
Dim objData As New DataObject
Set objConn = New ADODB.Connection
objConn.Open "st2000"
objData.SetText strSQL
objData.PutInClipboard
Set objRes = objConn.Execute(strSQL)
objConn.Close
Set objRes = Nothing
Set objConn = Nothing
End Sub
***SQL Code***
INSERT INTO TABLE VALUES (62, "1", "2", "3", "4", "5", "6", "", "", "",
"", "", "", "", "", "Other:", "", "", "", "", "", "", "", "", "", "",
"", "Other:", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "");