Returning a recordset from a Stored Procedure... what am I missing?  
Author Message
Chrisper69





PostPosted: .NET Framework Data Access and Storage, Returning a recordset from a Stored Procedure... what am I missing? Top

It seemed simple enough, and I think it probably is, but I've tried a dozen ways and wasted a day.

First, the simple stored procedure, existing in a SQL 2000 database:

CREATE PROCEDURE [dbo].[insertNewDir]

)
AS
BEGIN


END
GO

If I call this in Query Analyzer, it works just fine. No problem.

If I create a connection and pass the same SQL to try and get a recordset, the SP creates the record, but the recordset returned is closed. No errors.

Dim objCon As New ADODB.Connection
Dim oConnect As clsDataConnect = Me.GetConnected()
Dim oRS As New ADODB.Recordset

oRS.Open(sSQL, objCon)

and

oRS = objCon.Execute(sSQL)

Both fail the same way, as well as many, many other ways of calling it. (Specifying command text, cursors, connection options and other variations, both from the connection object and the recordset object.)

Any ideas




.NET Development12  
 
 
ShEi





PostPosted: .NET Framework Data Access and Storage, Returning a recordset from a Stored Procedure... what am I missing? Top

Dim myConnection As New OleDbConnection(Connectionstring)

myConnection.Open()

Dim myCommand As New OleDbCommand(StoredProcedure, myConnection)

myCommand.ExecuteNonQuery()

Dim myAdapter As New OleDbDataAdapter(myCommand)

Dim myDataset As New DataSet()

myConnection.Close()

myAdapter.Fill(myDataset)

Return myDataset