Link to home
Start Free TrialLog in
Avatar of momar
momar

asked on

Run-Time Error, what's wrong?

Why do I get the following error in VB when I run this code?  Heh I haven't done vb in a very long time, so the answer may be simple....

[ODBC Microsoft Access Driver]Too Few Parameters
Expected 1

Code:

 sqlStringInventory = "Select PartNumber, PartName, Quanitity, Price, DatePurchased, Description From Inventory Where PartNumber = '" & txtPartNum.Text & "'"
     Connect_Inventory (sqlStringInventory)
     Set dgInventory.DataSource = rsInventory

Public Sub Connect_Inventory(sqlString)
    Set db1 = New ADODB.Connection
    db1.Open "Provider=MSDASQL;DSN=AdinSystem"
    Set rsInventory = New ADODB.Recordset
    rsInventory.Open sqlString, db1, adOpenKeyset, adLockPessimistic
End Sub

Any help would be great, thanks
Avatar of willisp
willisp

HI Momar,

What is dgInventory?  I don't see the declaration.

Avatar of momar

ASKER

It's a DataGrid, just wanted to display the results in a DataGrid.
ASKER CERTIFIED SOLUTION
Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
my guess is that PartNumber is defined as a numeric on the DB, but you are passing a string in.

Change to:

sqlStringInventory = "Select PartNumber, PartName, Quanitity, Price, DatePurchased, Description From Inventory Where PartNumber = " & val(txtPartNum.Text)