Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adodc1.refresh method causes an error message

Status
Not open for further replies.

tadez

Programmer
Nov 9, 2002
6
0
0
SB
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.
 
Hi,

That error message can come up if the sql statement used is incorrect/invalid.

Try checking the stored procedure to see if it does actually work/exist

Acquiesce
 
Thank you Acquiesce for you response. The query works when opened in Access and when code is run in VB, Rs(0), Rs(1), values etc, can be seen when in debug mode. Have I missed out some settings in the ADO Data Control?

Tadez
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top