What is wrong here?
How do you update a DB when users are trying to update their personal info?
Below is the code.
Code:'-- Declare your variables
Dim DataConnection, cmdDC, RecordSet, SQL, strError
Dim strLastName, strFirstName, strPassword, strEmail, strUserID
Dim strAddress, strState, strZipCode, strPhone
'-- Get data from the form fields
strLastName = Request.Form("name")
strFirstName = Request.Form("name1")
strAddress = Request.Form("address")
strState = Request.Form("state")
strZipCode = Request.Form("zipcode")
strPhone = Request.Form("phone")
strPassword = Request.Form("password")
strEmail = Request.Form("email")
strUserID = Request.Form("userID")
'-- Create object and open database
Set DataConnection = Server.CreateObject("ADODB.Connection")
DataConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & DatabasePath & ";"
Set cmdDC = Server.CreateObject("ADODB.Command")
cmdDC.ActiveConnection = DataConnection
End If
'-- default SQL
SQL = "SELECT * FROM UserRegistration"
If Request.Form("name") <> "" Then
SQL = "SELECT Register.userID, Register.password, Register.email FROM Register WHERE " & _
"Register.userID='" & strUserID & "' OR " & _
"Register.password ='" & strPassword & _
"' OR Register.email ='" & strEmail & "'"
End If
cmdDC.CommandText = SQL
Set RecordSet = Server.CreateObject("ADODB.Recordset")
'-- Cursor Type, Lock Type
'-- ForwardOnly 0 - ReadOnly 1
'-- KeySet 1 - Pessimistic 2
'-- Dynamic 2 - Optimistic 3
'-- Static 3 - BatchOptimistic 4
RecordSet.Open cmdDC, , 3, 3
'-- Add new record to the database
Dim Dconn, sSQL
Set Dconn = Server.CreateObject("ADODB.Connection")
Dconn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & _
DatabasePath & ";"
sSQL = "INSERT INTO Register(FirstName, LastName, address, state, zipcode, phonenumber, email, userID, " & _
"password, userLevel) VALUES ('" & strFirstName & _
"','" & strLastName & "','" & strAddress & "','" & strState & _
"','" & strZipCode & "','" & strPhone & "','" & strEmail & _
"','" & strUserID & "','" & strPassword & "',1)"
Dconn.Execute sSQL
Dconn.Close
Set Dconn = Nothing
