I am attempting to populate an Adodc1 after accessing a stored MSAccess2000 query using the following codes;
Dim conn As New ADODB.Connection
Dim param1 As New ADODB.Parameter
Dim Cmd As New ADODB.Command
Dim Rs As New ADODB.Recordset
.....
Private Sub cmdGetQueryResult_Click()
Set Rs = New ADODB.Recordset
Set param1 = Cmd.CreateParameter("ParameterName", adSmallInt, adParamInput, 2)
With Cmd
Set .ActiveConnection = conn
.CommandText = "QueryName"
.CommandType = adCmdStoredProc
.Parameters.Append param1
.Parameters("ParameterName" = 78 ' 78 is the numeric value passed to query
Set Rs = .Execute()
End With
Set Me.Adodc1.Recordset = Rs
Me.Adodc1.Refresh
Me.datagrid1.Rebind
Me.datagrid1.HoldFields
Rs.Close
End Sub
Every time I reach the Me.Adodc1.Refresh line, (when running the program in debug mode) the message "Too few parameters. Expected 1." appears
When I look at the Datagrid display the required data is presented, but just that this message always comes up. Grateful if someone can advise me as to what I am not doing correctly. Thanks.
Dim conn As New ADODB.Connection
Dim param1 As New ADODB.Parameter
Dim Cmd As New ADODB.Command
Dim Rs As New ADODB.Recordset
.....
Private Sub cmdGetQueryResult_Click()
Set Rs = New ADODB.Recordset
Set param1 = Cmd.CreateParameter("ParameterName", adSmallInt, adParamInput, 2)
With Cmd
Set .ActiveConnection = conn
.CommandText = "QueryName"
.CommandType = adCmdStoredProc
.Parameters.Append param1
.Parameters("ParameterName" = 78 ' 78 is the numeric value passed to query
Set Rs = .Execute()
End With
Set Me.Adodc1.Recordset = Rs
Me.Adodc1.Refresh
Me.datagrid1.Rebind
Me.datagrid1.HoldFields
Rs.Close
End Sub
Every time I reach the Me.Adodc1.Refresh line, (when running the program in debug mode) the message "Too few parameters. Expected 1." appears
When I look at the Datagrid display the required data is presented, but just that this message always comes up. Grateful if someone can advise me as to what I am not doing correctly. Thanks.