I am attempting to populate an Adodc1 control on a form 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. Adodc1 is an ADO Data control on a form, hence the reference Me.Adodc1.Recordset. In the VB6 program I am creating, I have named it "adcProdID". The code resides behind a button on the form and when it is pressed, the code should load the required data into a Datagrid binded to the ADO data control. The required data is shows up on the datagrid, however just that the statedmessage 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. Adodc1 is an ADO Data control on a form, hence the reference Me.Adodc1.Recordset. In the VB6 program I am creating, I have named it "adcProdID". The code resides behind a button on the form and when it is pressed, the code should load the required data into a Datagrid binded to the ADO data control. The required data is shows up on the datagrid, however just that the statedmessage always comes up. Grateful if someone can advise me as to what I am not doing correctly. Thanks.