Problem ( Bug ?? ) with ADODB ( 2.1, 2.5, 2.6 SP1 ) 
Author Message
 Problem ( Bug ?? ) with ADODB ( 2.1, 2.5, 2.6 SP1 )

HI

A problem with ADODB Recordset ( 2.1, 2.5, 2.6 SP1) ?

If we have a Stored Procedure on SQL Server 2000
which has both an ( Update or Insert or Delete )
and a Select which returns a Result Set then the
ADODB Recordset does not return the Result Set of
the Select in the Stored Procedure.

When such a Stored Procedure is called using ADODB
with the SQLOLEDB provider for SQL Server 2000,
the ADODB Recordset gives an error when an attempt
is made the access the Recordset.

The following setup simulates this problem with the
ADODB Recordset

1. A table "tblADODBTest" with two columns "Col1" "Col2"
TSQL for creating the table:

create table tblADODBTest
( Col1 varchar(10), Col2 varchar(10) )
go

2. A Stored Proc with an Insert and a Select.
TSQL for creating the a :

create proc pr_ADODBTest as
begin

insert into tblADODBTest
values ( 'Val1', 'Val2' )

select * from tblADODBTest

end
go

3. VB code that call the Stored Procedure "pr_ADODBTest"
using ADODB and SQLOLEDB provider for SQL Server 2000.

Sub ADODBTest()

    Dim oRs As ADODB.Recordset
    Dim oCmd As ADODB.Command
    Dim oConn As ADODB.Connection

    Dim sConnection As String
    Dim sProcName As String

    sConnection = "Provider=SQLOLEDB;Data Source=SomeDBServer;Initial
Catalog=SomeDB;User Id=sa;Password=SomePassword;"
    sProcName = "pr_ADODBTest"

    Set oConn = New ADODB.Connection
    With oConn

        .CursorLocation = adUseClient
        .ConnectionTimeout = 15
        .IsolationLevel = adXactReadUncommitted
        .Open sConnection

    End With

    Set oCmd = New ADODB.Command
    With oCmd

        Set .ActiveConnection = oConn
        .CommandTimeout = 30
        .CommandType = adCmdStoredProc
        .CommandText = sProcName

    End With

    Set oRs = oCmd.Execute()

    ' The state is closed ??!!
    Debug.Print oRs.State

    ' This is where we get an error since the
    ' Recordset is closed. ( The Recordset never opened ?? )
    oRs.ActiveConnection = Nothing

    ' The execution never reaches this point
    Dim vResultSet As Variant
    If Not oRs.EOF Then
        avarResultSet = oRs.GetRows()
    End If

End Sub

The above VB Code works fine when the Insert statement is removed
from the Stored Procedure "pr_ADODBTest"

Is this a bug ? Is there any solution or work around to
this problem ?

Thanks and Regards
Rahul



Tue, 06 Jan 2004 02:50:49 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. MDAC 2.6 on the Server and MDAC 2.1 on the Client - Big Problems

2. MDAC 2.6 on the Server and MDAC 2.1 on the Client - Big Problems

3. SQL7 and MDAC 2.1 SP1 Bug

4. Problem developing dll files in MDAC 2.5, but using MDAC 2.6

5. performance problems from MDAC 2.1 to 2.5

6. Problems Upgrading from 2.1 to 2.5 with Async Command/Connection

7. From ADO 2.1 to 2.6

8. ADO 2.0, 2.1, 2.5, 2.6, ...... ??????

9. Service Pack 5 and MDAC 2.5 vs 2.6

10. Install MDAC 2.5 over MDAC 2.6

11. ADO 2.5 or 2.6

12. MDAC 2.5/2.6 installation on Win98

 

 
Powered by phpBB® Forum Software