Results 1 to 1 of 1
  1. #1
    Join Date
    Mar 2004
    Posts
    18

    Unanswered: RDO Cursor Error due to Connection Property

    In Visual Basic 6.0, after executing the CommitTrans/RollbackTrans methods of the RDO connection object, the following error occurs if you try to move the cursor around (for example, rs.MoveNext), query the column value (for example, debug.print rs(0)), or refresh the cursor (for example, rs.Move 0):
    Run-time error '40088':
    No open cursor or cursor closed.

    I have got solution for such error in case of SQL server & VB can anybody tell me about Sybase
    Following is solution

    Can u tell me how to mention SQL_PRESERVE_CURSORS for Sybase connection while opening RDO connection

    Step-by-Step Example
    1. Start a new project in Visual Basic and choose "Standard EXE." Form1 is created by default.
    2. From the Project menu, select References, and then choose Microsoft Remote Data Object 2.0.
    3. Add a CommandButton to Form1.
    4. Paste the following code in the General Declaration section of Form1:
    Option Explicit
    Const SQL_PRESERVE_CURSORS As Long = 1204
    Const SQL_PC_ON As Long = 1
    Const SQL_PC_OFF As Long = 0
    Private Declare Function SQLSetConnectOption Lib "odbc32.dll" _
    (ByVal hdbc&, ByVal fOption%, ByVal vParam As Any) As Integer
    Private Sub Command1_Click()
    Dim en As rdoEnvironment
    Dim cn As rdoConnection
    Dim rs As rdoResultset
    Dim strConnect As String
    Dim strSQL As String
    Dim intRet As Integer

    strConnect ="Driver={SQLServer};
    Server=MyServer;Database=Pubs;Uid=sa;Pwd=;"
    Set en = rdoEnvironments(0)
    en.CursorDriver = rdUseServer

    Set cn = New rdoConnection
    intRet = SQLSetConnectOption(cn.hdbc, SQL_PRESERVE_CURSORS, _
    SQL_PC_ON)
    cn.Connect = strConnect
    cn.EstablishConnection rdDriverNoPrompt, False

    strSQL = "Select au_id, au_lname from authors"
    Set rs = cn.OpenResultset(Name:=strSQL, Type:=rdOpenKeyset, _
    LockType:=rdConcurValues)

    cn.Execute "Begin Transaction", rdExecDirect
    rs.MoveFirst
    rs.Edit
    rs(1) = "Vermont"
    rs.Update
    cn.Execute "Commit Transaction", rdExecDirect
    Debug.Print rs(1)

    End Sub
    Last edited by prasadattcs; 03-17-04 at 10:43.

Posting Permissions

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