Is it possible to have a stored procedure return multiple ref cursors to a .Net application?
I tried this, but it didn't work.
<code>
While odr.Read()
dtUserData.Load(odr, LoadOption.OverwriteChanges)
End While
odr.NextResult()
While odr.Read()
dtUserRoles.Load(odr, LoadOption.OverwriteChanges)
End While
xgamma
Member
18 Points
66 Posts
Stored Procedure returning multiple ref cursors
Nov 22, 2010 03:08 PM|LINK
Hi,
Is it possible to have a stored procedure return multiple ref cursors to a .Net application?
I tried this, but it didn't work.
<code>
While odr.Read()
dtUserData.Load(odr, LoadOption.OverwriteChanges)
End While
odr.NextResult()
While odr.Read()
dtUserRoles.Load(odr, LoadOption.OverwriteChanges)
End While
</code>
HusamKhoulah
Participant
1470 Points
217 Posts
Re: Stored Procedure returning multiple ref cursors
Nov 22, 2010 04:33 PM|LINK
Hi
Check the Following code :
static void RetrieveMultipleResults(SqlConnection connection) { using (connection) { SqlCommand command = new SqlCommand( "SELECT CategoryID, CategoryName FROM dbo.Categories;" + "SELECT EmployeeID, LastName FROM dbo.Employees", connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.HasRows) { while (reader.Read()) { //do something } reader.NextResult(); } } }if this helps please mark as an Answer
regards
SqlDataReader.NextResult