Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a access table with an ID field that is auto incremented.

 

Problem is, I cant seem to do update query's 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

Posted

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!!!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...