AlexPonnath
asked on
VB.Net Datareader How to access more than one table
I have a Stored procedure which is called from my VB.Net app which returns more than on resault.
It actual has 3 diffrent resaults it will return with in the query. My question is how do i access the
diffrent tables / resaults within the reader object ?
It actual has 3 diffrent resaults it will return with in the query. My question is how do i access the
diffrent tables / resaults within the reader object ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>Actually NextResult method is useful if you have more than one query that certainly doesn't suit in your case.
well, I think I cannot agree ... because of:
<...> It actual has 3 diffrent resaults it will return with in the query. <..>
of course, we would need to know the procedure code to be 100% sure...
and also some feedback of the author :-)
well, I think I cannot agree ... because of:
<...> It actual has 3 diffrent resaults it will return with in the query. <..>
of course, we would need to know the procedure code to be 100% sure...
and also some feedback of the author :-)
Ok, could you demonstrate how to use the dataReader.NextResult() against SP ?
Thanks :)
Thanks :)
see the article I linked to. just replace the:
strSql = _
"SELECT CategoryName FROM Categories ORDER BY CategoryName;" _
& "SELECT Top 10 CompanyName FROM Customers ORDER BY CompanyName;" _
& "SELECT LastName FROM Employees ORDER BY LastName;" _
& "SELECT Top 10 ProductName FROM Products ORDER BY ProductName;"
by:
strSql = "Exec procedurename"
and you have it.
strSql = _
"SELECT CategoryName FROM Categories ORDER BY CategoryName;" _
& "SELECT Top 10 CompanyName FROM Customers ORDER BY CompanyName;" _
& "SELECT LastName FROM Employees ORDER BY LastName;" _
& "SELECT Top 10 ProductName FROM Products ORDER BY ProductName;"
by:
strSql = "Exec procedurename"
and you have it.
Althrough i have never tested something like that, if it works then i believe that your suggestion is actually solution for the Alex's problem.
Cheers :)
Cheers :)
Rather you have a Stored Procedure which returns concrete results.
So you should do nothing specific in order to display data that SP does return.
For example:
Dim selectCommand As SqlCommand = New SqlCommand()
selectCommand.CommandText = "sp_GetSomething"
selectCommand.CommandType = CommandType.StoredProcedur
selectCommand.Connection = connection
connection.Open()
Dim reader As SqlDataReader = selectCommand.ExecuteReade
Do While reader.Read
' DO something here
Loop
reader.Close()
connection.Close()
HTH
Regards :)