updating database with oledb parameterized query

dfk

New member
Joined
Oct 9, 2006
Messages
2
Programming Experience
Beginner
hi, i'm a newbie trying to update a single record in vb using access database. an oleDbException was unhandled error occured at the 'dbCommand.ExecuteNonQuery()' line.

it says no value is give for one or more parameters. although i did not leave the textbox fields empty during runtime. is it possible to update a record with empty values or original value?:confused:
thanks..

VB.NET:
dbCommand.Connection = con
dbCommand.Connection.Open()

dbCommand.CommandText = "UPDATE Table SET T_name = @nm, T_telno = @tel WHERE T_index = @id"

dbCommand.Parameters.AddWithValue("@nm", nameTextBox.Text)

dbCommand.Parameters.AddWithValue("@tel", telTextBox.Text)

dbCommand.ExecuteNonQuery()
dbCommand.Connection.Close()
 
Not in this particular query, no, You have a placeholder for a parameter in the WHERE clause but you havent added the parameter. So it won't work. just add the parameter, with something like this at the end..


VB.NET:
.SourceVersion = DataRowVersion.Original
 
thanks for the reply. i forgot to add the parameter for id:
dbCommand.Parameters.AddWithValue("@id", form1.id.ToString)

:p
 
Back
Top