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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Too few parameters. Expected 1. error message when refresh Adodc1

Status
Not open for further replies.

tadez

Programmer
Nov 9, 2002
6
SB
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.
 
This statement should refresh the Form recordset.
Set Me.Recordset = Rs

What is Adodc1? A Form? A control?
 
Adodc1 is an ADO Data control on a form, hence the reference Me.Adodc1.Recordset. In the VB program I am building, 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.
 
Since this refers to Visual Basic controls, it would be better to post in the Visual Basic Forum. This Forum is more for Access type questions.
 
Thanks. I am new and finding my way around a bit confusing. Thanks for the advice and will re-submit in the suggested forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top