Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   problem for unclosed quotation mark before the character string ''' (http://www.go4expert.com/forums/unclosed-quotation-mark-character-string-t2433/)

waiwaisan 4Jan2007 09:19

problem for unclosed quotation mark before the character string '''
 
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

shabbir 4Jan2007 10:45

Re: problem for unclosed quotation mark before the character string '''
 
You have posted it as an Article under the Article / Source code section. I have moved it to the Queries and Discussion forum.

Duplicate of problem for unclosed quotation mark before the character string '''. Thread closed.


All times are GMT +5.5. The time now is 08:34.