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

Problem with UPDATE sql command not changing values on VB form

Status
Not open for further replies.

Erbium

Programmer
Aug 30, 2007
22
US
Hi all

I've got a vb 2005 form with textboxes for data from fields and buttons: read, write, update, del

I've got it querying an access database, and grabbing data from a table.

Read works, if record already present, does a SELECT
write works, if record NOT present, does an INSERT
del works, the record is gone after I click this, does DELETE

but for the life of me I can't get UPDATE to work.
I've tried single and double quotes, ';' at end or not,
and just one or two values in the database. I've looked in SQL for Dummies, syntax appears to be OK.

E.G.
UPDATE Nodes SET showid = showid.text WHERE nodeid = '7';

and then same command execute logic as in other buttons.

I actually stop and put the sql it is sending into a message box when it hits the UPDATE command. Looks OK.

What is weirder is that it doesn't appear to be erroring in sql as it never hits the 'catch' area. When I try write button (with 'INSERT' SQL command behind it) it does hit catch area under its button if exists.

Any ideas? I'm at Witt's End, in a maze of twisty little passages, totally lost
 
not sure what ur actual sql statment is, but u could try this:

dim sqlStmt as sting = "update nodes set showid ='" & showid.text.Trim() & "' WHERE nodeid = '7'"

or if the showid is a number in the db converr it first. i.e.

dim sqlStmt as sting = "update nodes set showid ='" & integer.parse(showid.text) & "' WHERE nodeid = '7'"

also is the showid a key field? if so is referential integrity being invalidated (although this should throw an error).
 
I'll try the trim. Was inputting from text box so didn't even think might be interpreted as a number. Only nodeid is a key, no other fields even indexed.

Still haven't figured out why update not working or throwing an error when it fails to update the values.

However I substituted a delete then insert. If the delete throws to the catch err handler, I then do the insert anyway. It works but I want to know why update not working with ms access. Maybe something weird about msacess sql?

Thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top