Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2005

    Unanswered: i have problem regarding SELECT query statements in VB6

    i have problem regarding SELECT query statements in VB6. I want to open the record in a database. that record has an appostrophy or single quote symbol becuase it contains words with "appostrophy s". when i want to retrieve it, and place it in the textbox, there is a runtime error explains syntax error (missing operator)in the query expression = '. how to solve that runtime error. this is example of code:

    Private Sub listenglish_ItemClick(ByVal Item As MSComctlLib.ListItem)
    Dim rstpos As Recordset
    Set rstpos = New Recordset
    If rstpos.State = adStateOpen Then
    End If
    rstpos.CursorLocation = adUseClient
    rstpos.CursorType = adOpenDynamic
    rstpos.LockType = adLockOptimistic
    With rstpos
    .ActiveConnection = mcnnproj
    .Source = "SELECT english from translation where english ='" & listenglish.SelectedItem & "'"
    End With

    RichTextBox1.Text = rstpos!english

    Set rstpos = Nothing

    End Sub

    my problem here is in: "SELECT english from translation where english ='" & listenglish.SelectedItem & "'"

    Hope anyone will help me in this problem. i need to solve this problem immediately. thanks


  2. #2
    Join Date
    Oct 2004
    In cousin's house


    You can used a parameter query or a Stored procedure.

  3. #3
    Join Date
    Jan 2005
    Can u just give me the error message that appears in the screen. Hope i could help u

  4. #4
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    I'd use ADO parameter substitution (using ?), or I'd use a function to handle quoting for my code.

    The problem is that in SQL syntax, a quote ends a string. To get a literal apostrophe, you need to double it, like:
    SELECT 'I can''t get apostrophes past SQL any other way!'
    Using the ADO parameter routines does this quoting "automagically" for you.


Posting Permissions

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