patrick24601
Active member
- Joined
- May 16, 2005
- Messages
- 34
Is it possible to return the results of a stored procedure as an ASp.net dataset? Can I get some hints? I have been looking but cannot seem to find any examples.
Dim cmd As New SqlCommand
Dim conn As New SqlConnection(hpdmdbConnString)
Dim counter As Integer
cmd.Connection = conn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "usp_rolelookup"
cmd.Parameters.Add("@username", currentuser)
Open the connection
conn.Open()
And run the stored procedure command we have set up in CMD
objreader = cmd.ExecuteReader
Did we get any rows back? If so then loop through our objreader and add the single column of data
to the arraylist.
counter = 0
If objreader.HasRows Then
While (objreader.Read())
counter = counter + 1
getUserRoles.Add(objreader.GetString(0))
End While
End If
Dim MyAdapter As New SqlClient.SqlDataAdapter("usp_rolelookup", conn)
Dim MyDataset As New DataSet
set the command type
MyAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
add the parameters
MyAdapter.SelectCommand.Parameters.Add("@username", currentuser)
Use the dataadapter to fill the dataset
MyAdapter.Fill(MyDataset)
If MyDataset.Tables.Count > 0 Then
do somthing with the dataset
End If