Go to: Articles List

How to update a database record:

'Do database connection
'Declare variables
sql = "update MyTable set"
sql = sql & "Field1 = '" & VAR1 & "',"
sql = sql & "Field2 = '" & VAR2 & "',"
sql = sql & "Field3 = '" & VAR3 & "' "
sql = sql & "where Field4 = '" & VAR4 & "'"
Conn.Execute(sql)

The first thing that this code does is point to the table that is going to be updated. In this case it is a table that is called MyTable. You will need to rename this to the name of the table you are trying to update. FieldX is the actual name of the field that you are working with, so don't forget to change those.

Notice that the last column to be updated has a " " at the end instead of a ",". Then the last line tells the script exactly what record to update. Here is another example of what the "where Field4 = " line could be:

sql = sql & "Where MemberUserId = '" & MemberId & "'"

By: Josh Olson