problem for unclosed quotation mark before the character string '''

Discussion in 'Visual Basic ( VB )' started by waiwaisan, Jan 4, 2007.

Thread Status:
Not open for further replies.
  1. waiwaisan

    waiwaisan New Member

    Joined:
    Jan 4, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hihi

    Anyone cam help me? I am facing this problem when I key in the ' (apostrophe) then it occur runtime error.

    This is the code
    Code:
    'Method name: query
    'Method Description: to run select-statement and return the results
    'Parameters pass in: s (SQL select-statement)
    ' : cursorType (cursorType for connection)
    ' : lockType (connection lock type)
    'Parameters return: query (recordset that stores the results)
    
    Public Function query(ByVal sql As String, _
    Optional ByVal cursorType As CursorTypeEnum = adOpenForwardOnly, _
    Optional ByVal lockType As LockTypeEnum = adLockReadOnly) As ADODB.Recordset
    
    On Error GoTo errHdl
    Set query = New ADODB.Recordset
    With query
    .CursorLocation = adUseClient
    .Open sql, con, cursorType, lockType
    Debug.Print Time & " sql queried" & vbNewLine & _
    vbTab & sql & vbNewLine & _
    vbTab & "with " & query.RecordCount & " row(s) returned"
    .ActiveConnection = Nothing
    End With
    Exit Function
    
    errHdl:
    Debug.Print Time & " error query sql" & vbNewLine & _
    vbTab & sql & vbNewLine & _
    vbTab & Err.description
    Err.Raise Err.Number, "DB.query", Err.description <------- error
    
    End Function
    
    Hope anyone can help me. Thanks
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice