Binding the result set from a called stored procedure

A

Alex

Hello All,
I am new to ASP.Net and would like to know how to place
the results from a stored procedure that I call into another form
within my project. Currently, I can see my results in my grid that I
bind to, but have not a clue how to write the results into the
(practice.aspx) page with the different text objects on the form. I'm
passing one parameter that is entered by the user from the first web
page. Here is my code.

Dim objConn As New SqlConnection
Dim Selection As String
Dim spName As String
objConn.ConnectionString =
"Server=IS-5NGB721;Database=Pistol_Test;Trusted_Connection=True;"
objConn.Open()
Dim tbl_will As New DataTable
spName = DropDownListSelect.SelectedItem.Value
Dim find_will As SqlCommand = New SqlCommand("sel_data",
objConn)
find_will.Parameters.Add("@license", Me.TextBoxSelect.Text)
find_will.CommandType = CommandType.StoredProcedure
find_will.ExecuteNonQuery().ToString()
Dim adap As SqlDataAdapter = New SqlDataAdapter(find_will)
adap.Fill(tbl_will)
Me.DataGrid1.DataSource = tbl_will
Me.DataGrid1.DataBind()
objConn.Close()
End Sub


Thanks is advance for your help....

Alex
 
G

Guest

Alex,
first of all you are posting VB.NET sample code to the C# newsgroup. No
biggie, but the VB.NET group would be more appropriate.

I'd do this:

adap.Fill(tbl_will)
Session("tbl_will")=tbl_will
Me.DataGrid1.DataSource = tbl_will

Your DataTable is now in Session, and you should be able to pull it out and
use it on any page. If it's not user-specific, you could store it in Cache or
even in Application scope.
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top