Problem with the ID field

sjn78

Well-known member
Joined
May 4, 2003
Messages
255
Location
Australia
I have a access table with an ID field that is auto incremented.

Problem is, I cant seem to do update querys when i use the ID field.

I narrow my selection to the person I want to make the updates to and then grab the id of the row and assign it to playid.

Dim objCommand As New OleDbCommand("UPDATE Contacts WHERE ID = " & playid & _
" SET Firstname = " & StrConv(txtFirstname.Text, VbStrConv.ProperCase) & _
", MiddleName = " & StrConv(txtMiddleName.Text, VbStrConv.ProperCase) & _
", Surname = " & StrConv(txtSurname.Text, VbStrConv.ProperCase) & _
"", cnn)

I end up getting this error:

An unhandled exception of type System.Data.OleDb.OleDbException occurred in system.data.dll

I have found though, if I change the objcommand to update where the surname = something, it works fine.

Has anyone come across this or is it just me?

Thanks

Steve
 
Im slapping myself across the face now......

The id field is an integer and my syntax was telling it to look for text...eg, I had id as 2 instead of 2


Very silly mistake, but you learn by mistakes!!!
 
Back
Top