Click here to Skip to main content
15,914,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Is it possible to get the result of the 2nd Query of a stored procedure
When running the Stored on MySql it give 2 result but when applying it on my App
this is my VB.NET Code for ASP.NET

VB
Using DataRead As MySqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
    If DataRead.HasRows() Then
        dt.Load(DataRead)
        If DataRead.HasRows Then
            If DataRead.Read Then
                Dim result As String = DataRead.GetString(0)
                Dim name As String = DataRead.GetString(1)
                DataRead.Close
            End If
        End If
    End If
End Using


Do I need to Close the DataReader if I only Load it to a datatable
VB
Using DataRead As MySqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
    If DataRead.HasRows() Then
        dt.Load(DataRead)
    End If
End Using


Does the Connection automatically closed using the cmd.ExecuteReader(CommandBehavior.CloseConnection) ?
Posted
Updated 2-Oct-13 17:57pm
v2

1 solution

Connection will be closed automatically using "Using".

If you want to store multiple result then the preferred way will be populating dataset instead of datareader. You can access the result using the index of the datatable starting from zero. For eg:

dsFill.Tables[0].Rows.Count;
 
Share this answer
 
Comments
iMaker.ph 4-Oct-13 5:54am    
How about using Datareader how can I get the same result. From what I understand Datareader is much faster due to its read only..

Btw thanks I get your point.. :) just wanna try using DataReader..
Madhu Nair 4-Oct-13 6:00am    
:)... Please let me know also if you find any solution using Datareader

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900