D
Duppypog
I'm trying to update a record in an Access database. When I click the submit
button on my form to execute the code, I'm getting an error, "Operation must
use an updateable query. "
To troubleshoot, I created the same query within the database, and it
updates the record. So why can't I get it to execute from my asp.net code?
PLEASE HELP!
Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSubmit.Click
'First test that new password is a strong password, if true, hash
the password
If ValidPWD(txtNewPW.Text) Then
Dim hshPW As String
hshPW =
FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text,
"sha1")
'Once you have a strong password, test that the username and
password match a valid user in the database
If ValidateUser(txtUsername.Text, hshPW) Then
'Next test that the two New PW textbox values match
If txtNewPW.Text = txt2NewPW.Text Then
Dim hshNewPW As String
hshNewPW =
FormsAuthentication.HashPasswordForStoringInConfigFile(txtNewPW.Text,
"sha1")
Dim strUser As String = txtUsername.Text
Dim d = Now.ToShortDateString
Dim sSQL As String
Dim dr As OleDbDataReader
Dim retVal As Boolean = False
Dim cnn As New
OleDbConnection(Constants.OleDbConnectionString)
cnn.Open()
sSQL = "UPDATE tblUsers SET strPASSWORD = '" & hshNewPW
& "' WHERE (strUserName = '" & strUser & "')"
Dim objCommand As OleDbCommand = New OleDbCommand(sSQL,
cnn)
dr = objCommand.ExecuteReader()
retVal = True
'FormsAuthentication.RedirectFromLoginPage(Session("sUser"), False)
Call SetSVariables()
Response.Redirect(Server.MapPath("CompPayOut.aspx"))
objCommand.Dispose()
dr.Close()
cnn.Close()
Else
lblErrorMsg.Text = "The new passwords you entered do not
match. Please type them again."
lblErrorMsg.Visible = True
End If
Else
lblErrorMsg.Text = "The username or password you entered do
not match a user in the database. Please try again."
lblErrorMsg.Visible = True
txtNewPW.Text = ""
txt2NewPW.Text = ""
End If
Else
lblErrorMsg.Text = "You must use a strong password, consisting
of a combination of numbers, special characters and UPPER and lower case
letters. Please try again."
lblErrorMsg.Visible = True
End If
End Sub
button on my form to execute the code, I'm getting an error, "Operation must
use an updateable query. "
To troubleshoot, I created the same query within the database, and it
updates the record. So why can't I get it to execute from my asp.net code?
PLEASE HELP!
Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSubmit.Click
'First test that new password is a strong password, if true, hash
the password
If ValidPWD(txtNewPW.Text) Then
Dim hshPW As String
hshPW =
FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text,
"sha1")
'Once you have a strong password, test that the username and
password match a valid user in the database
If ValidateUser(txtUsername.Text, hshPW) Then
'Next test that the two New PW textbox values match
If txtNewPW.Text = txt2NewPW.Text Then
Dim hshNewPW As String
hshNewPW =
FormsAuthentication.HashPasswordForStoringInConfigFile(txtNewPW.Text,
"sha1")
Dim strUser As String = txtUsername.Text
Dim d = Now.ToShortDateString
Dim sSQL As String
Dim dr As OleDbDataReader
Dim retVal As Boolean = False
Dim cnn As New
OleDbConnection(Constants.OleDbConnectionString)
cnn.Open()
sSQL = "UPDATE tblUsers SET strPASSWORD = '" & hshNewPW
& "' WHERE (strUserName = '" & strUser & "')"
Dim objCommand As OleDbCommand = New OleDbCommand(sSQL,
cnn)
dr = objCommand.ExecuteReader()
retVal = True
'FormsAuthentication.RedirectFromLoginPage(Session("sUser"), False)
Call SetSVariables()
Response.Redirect(Server.MapPath("CompPayOut.aspx"))
objCommand.Dispose()
dr.Close()
cnn.Close()
Else
lblErrorMsg.Text = "The new passwords you entered do not
match. Please type them again."
lblErrorMsg.Visible = True
End If
Else
lblErrorMsg.Text = "The username or password you entered do
not match a user in the database. Please try again."
lblErrorMsg.Visible = True
txtNewPW.Text = ""
txt2NewPW.Text = ""
End If
Else
lblErrorMsg.Text = "You must use a strong password, consisting
of a combination of numbers, special characters and UPPER and lower case
letters. Please try again."
lblErrorMsg.Visible = True
End If
End Sub