0

umd = New OleDbCommand()
umd.CommandText = "UPDATE STUDENT SET roll = ' " + TextBox1.Text + " ' , name = ' " + TextBox2.Text + " ', marks = ' " + TextBox3.Text + " ' " & " WHERE roll = ' " + TextBox1.Text + " ' "
umd.Connection = con
con.Open()
umd.ExecuteNonQuery()
da.UpdateCommand = umd

con.Close()
ds.Clear()
da.Fill(ds, "student")

I am using the above code for updating a row in database (MS access) but its not working. Please help me in solving this. Thanx.

3
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by Teme64
0

Which part is not working? What error do you get?

At least using TextBox1.Text in both SET and WHERE seems a bit suspicious. If roll exists, you update roll-field with the same value it already has. If roll does not exists, then your update fails.

Also, open connection before you assign it to command:
con.Open()
umd.Connection = con

0

It is still the same.......I have removed the roll field from update and also I have opened connection before assigning it to a command..........

0

Do you get an error message? Or does your code "work" i.e. no error message, but the database will not be updated?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.