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

Using Parameter in OleDb command

Status
Not open for further replies.

GerardMcL

Technical User
Aug 5, 2004
212
IE
Hi (again),

Sorry about all the posts but I am eager to get a handle on this ADO.Net stuff.

I have executed commands and filled a combo box - was now hoping to take selected value and execute a further sql statement.

E.g.
ToolCode = Strings.Mid(cmbTools.Text, 1, 5) 'Returns correct Value

cn = New OleDbConnection(ConnString)
cn.Open()

cmd = New OleDbCommand("SELECT Price, BoughtDate FROM Tools WHERE ToolID = '" & ToolCode & "';")
dr = cmd.ExecuteReader
While dr.Read()
Me.txtPrice.Text = dr(0)
Me.txtBoughtDate.Text = dr(1)
End While


But at the line dr = cmdExecuteReader I get an error:
System.InvalidOperationException in system.data.dll

Why is this happening? Having trouble getting my head round this dataAdapter thing.
 
Got It - was just a problem with the SQL. My Bad!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top