[quote]I want to use three stored procedures with a dataset but don't know how to set it up[/quote]
Use a data adapter to load each stored procedure's data into a datatable in the dataset. Just change the command that that the data adapter uses in each case.
You don't really need to create 3 separate commands as you have done (above).
Try something like this (untested):
Dim ds as DataSet = New DataSet
ds.Tables.Add(new DataTable("Table1"))
ds.Tables.Add(new DataTable("Table2"))
ds.Tables.Add(new DataTable("Table3"))
Dim adapter As New Data.SqlClient.SqlDataAdapter
Dim cmd As Data.SqlClient.SqlCommand
' first sp
Set cmd = New Data.SqlClient.SqlCommand
With cmd
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "GetAllTopics"
.Connection = conn
If DropDownList2.SelectedValue = "-1" Then
.Parameters.AddWithValue("@Type", DropDownList2.SelectedValue)
End If
End With
adapter.SelectCommand = cmd
adapter.Fill(ds.Tables("Table1"))
' second sp
Set cmd = New Data.SqlClient.SqlCommand
With cmd
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "GetByTopic"
.Connection = conn
If DropDownList3.SelectedIndex > 0 Then
.Parameters.AddWithValue("@classificationid", Integer.Parse(DropDownList2.SelectedValue))
End If
End With
adapter.SelectCommand = cmd
adapter.Fill(ds.Tables("Table2"))
' third sp
Set cmd = New Data.SqlClient.SqlCommand
With cmd
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "GetByMedia"
.Connection = conn
If DropDownList3.SelectedValue > 0 Then
.Parameters.AddWithValue("@Mediaid", DropDownList3.SelectedValue)
End If
End With
adapter.SelectCommand = cmd
adapter.Fill(ds.Tables("Table3"))
This should give you a data set with 3 sources of data, which you can then use in whatever way you want.
Joe
Enter your message below
Sign in or Join us (it's free).