Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Textarea issue - please help!

    Hi guys!

    I have created a form to add some data into a database via ASP. I have a text area, but when I add words with an ', I get a syntax error. ie, that's, didn't, etc etc

    Is there a way from preventing this??

    Thanks!
    Daniel

  • #2
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok I just read the sticky thread on this

    here is my statement

    strSQL = "INSERT INTO jobs (Title,status,Salary,JobCategory,Hotjob,Contact,Duties,Qualifications,[Timestamp])VALUES('" & strTitle & "','" & numStatus & "','" & strSalary & "','" & strJobCategory & "','" & strHotjob & "','" & strContact & "','" & strDuties & "','" & strQualifications & "','" & date() & "')"
    adoCon.Execute(strSQL)

    where do I add the function?

    Thanks!

  • #3
    Regular Coder
    Join Date
    Sep 2004
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Any place that would contain characters in the database.
    Code:
    Function CSQ(byVal str)
         If IsNull(str) Then str = ""
         CSQ = Replace(str,"'","''")
    End Function
    
    strSQL = "INSERT INTO jobs (Title,status,Salary,JobCategory,Hotjob,Contact,Duties,Qualifications,[Timestamp])VALUES('" & CSQ(strTitle) & "','" & CSQ(numStatus) & "','" & CSQ(strSalary) & "','" & CSQ(strJobCategory) & "','" & CSQ(strHotjob) & "','" & CSQ(strContact) & "','" & CSQ(strDuties) & "','" & CSQ(strQualifications) & "','" & date() & "')" 
    adoCon.Execute(strSQL)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •