PDA

Click to See Complete Forum and Search --> : Update Statement


gsc1ugs
Jun 15th, 2001, 09:36 AM
Hi All,

I have a form that i populate using the id on the selected row:

Once i have edited the data i want to use an update statement or what ever is suitable to update the currently selected row. The form is populated using the filed name to put the currently held value in, once edited, i would like to update but i'm having problem getting the right update statement from the form... does anyone have an example or a solution to this problem.??

Many thanks Gary

monte96
Jun 15th, 2001, 10:56 AM
You'll need to build the update query string in code from your Request.Form() variables on the page the form is submitted to.

Something to the tune of:

strSQL = "Update tablename (field1, field2, field3,...) values(" & Request.Form("Field1") & ", " & Request.Form("Field2") & ", " & Request.Form("Field3") & ")"

Now, if any of these fields are strings, you will need to put single quotes 'around them':

strSQL = "Update tablename (field1, field2, field3,...) values('" & Request.Form("Field1") & "', '" & Request.Form("Field2") & "',' " & Request.Form("Field3") & "')"

Then just feed it to your Connection object's Execute method:

cnConn.Execute strSQL

gsc1ugs
Jun 18th, 2001, 04:26 AM
Cheers, i'll give it a whirl.