UPDATE

A

alexz

I'm trying to update my database fields
Employee, Status and Location with values from a form.
Is this going to work?

Dim strEmployee, strStatus, strLocation

strEmployee= request.form("Employee")
strStatus = Request.Form("Status")
strLocation = Request.Form("Location")

SQLstmt = "UPDATE Table SET "

SQLstmt = SQLstmt & "RS("Employee")= strEmployee"
SQLstmt = SQLstmt & "RS("Status")= strStatus"
SQLstmt = SQLstmt & "RS("Location")= strLocation"
 
R

Ray at

No, try this:

strEmployee= request.form("Employee")
strStatus = Request.Form("Status")
strLocation = Request.Form("Location")

SQLstmt = "UPDATE Table SET [Employee]='" & strEmployee & "',[Status]='" &
strStatus & "',[Location]='" & strLocation & "'"

That statement will update EVERY record though if you don't have a WHERE
clause, i.e. WHERE [EmployeedID]=6.

Ray at work
 
T

TurkBear

I'm trying to update my database fields
Employee, Status and Location with values from a form.
Is this going to work?

Dim strEmployee, strStatus, strLocation

strEmployee= request.form("Employee")
strStatus = Request.Form("Status")
strLocation = Request.Form("Location")

SQLstmt = "UPDATE Table SET "

SQLstmt = SQLstmt & "RS("Employee")= strEmployee"
SQLstmt = SQLstmt & "RS("Status")= strStatus"
SQLstmt = SQLstmt & "RS("Location")= strLocation"

It appears that you are not telling the database table which records to update ---So it may update all your existing
records
You may want to add something like

SQLstmt = SQLstmt & " Where some_field_in_the_table = some_field_to_identify_which_record_get_this_update"

( I am not sure what the RS refers to, since I do not see any Recordset )
 
A

alexz

TurkBear said:
It appears that you are not telling the database table which records to update ---So it may update all your existing
records
You may want to add something like

SQLstmt = SQLstmt & " Where some_field_in_the_table = some_field_to_identify_which_record_get_this_update"

( I am not sure what the RS refers to, since I do not see any Recordset )

Thanks, Got it working.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top