cwolgamott
Programmer
Hello. I am writing some ASP pages where I would like the user to be able to enter in a subject and description. Then, I would like to insert the subject and description into a SQL Server 2000 table. However, if the user enters an apostrophe or single quote in the subject or description, it errors out and will not insert the record into the table. Here is the code for how I am inserting the code into SQL:
SQL = " INSERT INTO CaseInfo (CaseInfo.casenum, CaseInfo.caller, CaseInfo.subject, CaseInfo.description, CaseInfo.assignedto, CaseInfo.openedby, CaseInfo.dateopened, CaseInfo.daterequested, CaseInfo.dateneeded, CaseInfo.dateestimated, CaseInfo.iscompleted, CaseInfo.respondedto, CaseInfo.percentcomplete, CaseInfo.status) "
SQL = SQL + "VALUES (" + CStr(newCaseNumber) + ", " + "'" + inputFullName2 + "', " + "'" + Request("subject" + "', " + "'" + Request("description" + "', " + "'" + "UNASSIGNED" + "', " + "'" + "INTRANET" + "', " + "GETDATE()" + ", " + "'" + dateVar + "', " + "'" + dateVar + "', " + "GETDATE()" + ", " + "'" + "N" + "', " + "'" + "N" + "', " + "0" + ", " + "'" + "NOT STARTED" + "')"
conn1.Execute(SQL)
I would greatly appreciate any help or suggestions. Thank you.
SQL = " INSERT INTO CaseInfo (CaseInfo.casenum, CaseInfo.caller, CaseInfo.subject, CaseInfo.description, CaseInfo.assignedto, CaseInfo.openedby, CaseInfo.dateopened, CaseInfo.daterequested, CaseInfo.dateneeded, CaseInfo.dateestimated, CaseInfo.iscompleted, CaseInfo.respondedto, CaseInfo.percentcomplete, CaseInfo.status) "
SQL = SQL + "VALUES (" + CStr(newCaseNumber) + ", " + "'" + inputFullName2 + "', " + "'" + Request("subject" + "', " + "'" + Request("description" + "', " + "'" + "UNASSIGNED" + "', " + "'" + "INTRANET" + "', " + "GETDATE()" + ", " + "'" + dateVar + "', " + "'" + dateVar + "', " + "GETDATE()" + ", " + "'" + "N" + "', " + "'" + "N" + "', " + "0" + ", " + "'" + "NOT STARTED" + "')"
conn1.Execute(SQL)
I would greatly appreciate any help or suggestions. Thank you.