Running the code below comes up with
"Run-time error '-2147217904 (80040e10)': [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1."
on the cmd.execute line.
Private Sub Command1_Click()
Const ConnectString = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=L:\HCUK Synergy\Generic\CWtoGM.mdb"
Dim param As ADODB.Parameter
Dim cmd As New ADODB.Command
Dim conn As New ADODB.Connection
conn.ConnectionTimeout = 10
conn.Open (ConnectString)
cmd.ActiveConnection = conn
cmd.CommandText = "Parameters [pCName] Integer; SELECT CWDATA.NAME FROM CWDATA WHERE CWDATA.ID = [pCName]"
cmd.CommandType = adCmdText
Set param = cmd.CreateParameter("[pCName]", adInteger, adParamInput)
cmd.Parameters.Append param
param.Value = 11
cmd.Execute
End Sub
I'm using VB6.0 and connecting to an Access 97 db. Replacing the [pCName] in the SQL statement with a literal '11' works so there's some problem with using parameters.
"Run-time error '-2147217904 (80040e10)': [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1."
on the cmd.execute line.
Private Sub Command1_Click()
Const ConnectString = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=L:\HCUK Synergy\Generic\CWtoGM.mdb"
Dim param As ADODB.Parameter
Dim cmd As New ADODB.Command
Dim conn As New ADODB.Connection
conn.ConnectionTimeout = 10
conn.Open (ConnectString)
cmd.ActiveConnection = conn
cmd.CommandText = "Parameters [pCName] Integer; SELECT CWDATA.NAME FROM CWDATA WHERE CWDATA.ID = [pCName]"
cmd.CommandType = adCmdText
Set param = cmd.CreateParameter("[pCName]", adInteger, adParamInput)
cmd.Parameters.Append param
param.Value = 11
cmd.Execute
End Sub
I'm using VB6.0 and connecting to an Access 97 db. Replacing the [pCName] in the SQL statement with a literal '11' works so there's some problem with using parameters.