Results 1 to 8 of 8

Thread: How to get single quotes in SQL? [Resolved]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    How to get single quotes in SQL? [Resolved]

    This is probably a simple question, but I've got a brain block. I have a textbox field, txtMessage.text, that is read into a variable strMsg. This is used in an SQL Insert statement below (previously I just read txtMessage.text in this spot).
    It saves just fine if there are no single quotes, i.e. apostrophes, in the text, but if there are, I get a syntax error. The user can't enter contractions because of this. How can I get this to allow single quotes? Thanks.
    VB Code:
    1. strSQL += CInt(txtInterviewerNum.Text) & ", "
    2.         If blnIsCAS Then
    3.             strSQL += "'" & strMsg & "', " & blnIsSent & ", " & blnIsNotSent & ")"
    4.         Else
    5.             strSQL += "#" & CDate(txtSvcDate.Text) & "#, '"
    6.             strSQL += strMsg & "', " & blnIsSent & ", " & blnIsNotSent & ")"
    7.         End If
    Last edited by salvelinus; Jan 14th, 2004 at 12:04 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width