Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL-Insert
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Miscellaneous
Thread ID:
00601657
Message ID:
00601737
Views:
28
This message has been marked as the solution to the initial question of the thread.
Doug,

With classic ADO this is the primary reason I use recordsets to perform updates instead of SQL inserts. The recordset object handles all of this for you with a very minor performance hit. It also handles the large string length problems associated with memo field inserts > 256 bytes.

'Get connected to the database.
set oConn = Server.CreateObject("ADODB.Connection")
set oRec = Server.CreateObject("ADODB.Recordset")
oConn.open "sf_login"
sql = "SELECT * from comments where 1=2" 'SQL to return empty recordset
oRec.Open sql, oConn, 0, 2
oRec.Addnew
oRec.fields("clientnum").value = q_clientnum
oRec.fields("name").value = q_name
oRec.fields("subject").value = q_subject
'.... rest of fields to populate
oRec.update
oRec.close
oConn.close

To me this is easier than building those huge SQL insert commands.
If your determined to use SQL inserts then you can create a function to parse the data for illegal characters. For Foxpro memo field the only characters you should have to parse would be single and double quotes. I don't know why a character such as a period would cause a problem.

q_comments = Prep_data(Request.Form("xcomments"))
q_contact = Prep_data(Request.Form("xcontact"))

function Prep_data(ldata)
ldata = replace(trim(ldata),"'","") 'get rid of any {'}
ldata = replace(ldata,"""","""""") 'replace any {"} with {""}
Prep_data = ldata
end function





>Hi everyone.
>
>Here's what I'm trying to do. I have a form that has a comments field on it, and when the user hits submit I email the form answers to my address. Using CDONTS is easy and great for this.
>
>But here's where I run into problems. I'm using the INSERT SQL Command to add a record to my feedback database. If the user enters any special characters, like period, comma...whatever....iget the syntax error or some other error.
>
>I'm using Foxpro databases(dbf) with a memo field for the comments. I've tried Macro Substituition with Vbscript, and i've also written the comments out to a text file. But I really need to know if there is a command that I can include in the SQL statement that will do the job quick and clean.
>
>Thanks.
Michael McLain
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform