Hi All...
I have a 'Notes' entry field on my screen and my users will be able to enter: don't forget to brush your teeth
We all know that SQL doesn't like the single apostrophe in don't... but is fine if you do:
Notes = Replace(Notes, ', '') which gives: don''t forget to brush your teeth
now if I Insert this directly using Query Analyzer -its all good..
but if I insert it using:
set cmdObj = Server.CreateObject("ADODB.Command"
set cmdObj.ActiveConnection = conObj
cmdObj.CommandText = "INSERT INTO Table1 (Date1, PersonID, Notes) VALUES(?, ?, ?)"
cmdObj.Parameters.Append cmdObj.CreateParameter("Date1", adDate, adParamInput, 8, ScreenDate)
cmdObj.Parameters.Append cmdObj.CreateParameter("PersonID", adInteger, adParamInput, 4, PersonID)
cmdObj.Parameters.Append cmdObj.CreateParameter("Notes", adVarChar, adParamInput, 255, Notes)
cmdObj.execute
it inserts to the database as don''t forget to brush yout teeth...
How can I fix up the above to either be equivalent to insert "don't forget to brush your teeth" or insert 'don''t forget to brush your teeth'
Worse case I'll change it to a straight insert statement -but I've inherited the code and would rather not...
Any advice appreciated
I have a 'Notes' entry field on my screen and my users will be able to enter: don't forget to brush your teeth
We all know that SQL doesn't like the single apostrophe in don't... but is fine if you do:
Notes = Replace(Notes, ', '') which gives: don''t forget to brush your teeth
now if I Insert this directly using Query Analyzer -its all good..
but if I insert it using:
set cmdObj = Server.CreateObject("ADODB.Command"
set cmdObj.ActiveConnection = conObj
cmdObj.CommandText = "INSERT INTO Table1 (Date1, PersonID, Notes) VALUES(?, ?, ?)"
cmdObj.Parameters.Append cmdObj.CreateParameter("Date1", adDate, adParamInput, 8, ScreenDate)
cmdObj.Parameters.Append cmdObj.CreateParameter("PersonID", adInteger, adParamInput, 4, PersonID)
cmdObj.Parameters.Append cmdObj.CreateParameter("Notes", adVarChar, adParamInput, 255, Notes)
cmdObj.execute
it inserts to the database as don''t forget to brush yout teeth...
How can I fix up the above to either be equivalent to insert "don't forget to brush your teeth" or insert 'don''t forget to brush your teeth'
Worse case I'll change it to a straight insert statement -but I've inherited the code and would rather not...
Any advice appreciated