Murray Brown
asked on
ASP.net strange error in Update query
Hi
I get an error in the following code
"Incorrect syntax in UPDATE Statement"
If I do exactly the same query in my Access database it works
Is it the Code that I am using
I get an error in the following code
"Incorrect syntax in UPDATE Statement"
If I do exactly the same query in my Access database it works
Is it the Code that I am using
Sub UpdateNewEmailAndPassword(ByVal sEmail As String, ByVal sPassword As String)
'// define a connection to the database
Dim cs As String = ConfigurationManager.ConnectionStrings("WhatEverNameYouWant").ConnectionString
cs = cs.Replace("App_Data\GC.accdb", Server.MapPath("App_Data\GC.accdb"))
Dim cn As New OleDbConnection(cs)
Try
Dim sSQL As String
sSQL = "UPDATE MyUsers SET Password = '" & sPassword & "' WHERE Email = '" & sEmail & "'"
'sSQL = "INSERT INTO MyUsers ( [Email], [Password], [FirstName], [Logins] ) SELECT '" & sEmail & "' AS Expr1, '" & sPassword & "' AS Expr2, '" & sFirstName & "' AS Expr3, '" & "First login " & CStr(System.DateTime.Today) & " Subsequent logins " & "'"
'// define the sql statement to execute
Dim cmd As New OleDbCommand(sSQL, cn)
' '// open the connection
cn.Open()
cmd.ExecuteNonQuery()
Catch ex As Exception
Response.Write(ex.Message)
Finally
If cn.State <> ConnectionState.Closed Then
cn.Close()
End If
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER