Forum Moderators: open
I have a problem updating my database.
If Request.Form("btnEdit") = "Update" Then
owname = Request.Form("txtname")
owemail = Request.Form("txtemail")
softname = Request.Form("txtswname")
softver = Request.Form("txtswver")
company = Request.Form("txtcom")
number = Request.Form("txtnum")
serial = Request.Form("txtserial")
date1 = Request.Form("txtdate")
date2 = Request.Form("txtldate")
Set rs2 = Server.CreateObject("ADODB.RecordSet")
'update record
sqlstr2 = "Update LicenseTab set" _
& " Ownername = '" & owname & "', " _
& " Owneremail = '" & owemail & "', " _
& " SwName = '" & softname & "', " _
& " SwVersion = '" & softver & "', " _
& " SwCompany = '" & company & "', " _
& " LicenseAmount = '" & number & "', " _
& " LicenseNumber = '" & serial & "', " _
& " LicenseDate = '" & date1 & "', " _
& " LicenseEndDate = '" & date2 & "', " _
& " Where id = ' & strID & '"
rs2.Open sqlstr2, connStr
End if My error message is:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'Where'.
/itls/slid/license_mod.asp, line 63
I thought i already break down the query but... :(
That should do it, as long as "id" is an interger field.
This is the result, seems fine doesnt it?
I realised i have a comma before where.. thats all
I can remember the hours spent trying to debug something like this, only to find a misplaced single quote or comma. I do so much of this dynamically, with variables and concatenation, that it's so easy to.
My best friend in all this is the Response.Write command. I can see exactly what I'm sending to the DB and where it fails and why I'm not getting the results I'm expecting.
MyVar = MyVar.Replace("'","''")
This will replace any single quote with two single quotes (it's an escape feature). When you read the data back from the database, there will just be one single quote.