I'm trying to use three stored procedures and three adapters but don't
know how to set it up. This is giving me errors. Can someone assist
me please.
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim conn As New
Data.SqlClient.SqlConnection(ConfigurationManager. ConnectionStrings("TrainUserConnectionString").Con nectionString)
Dim cmdALL As New Data.SqlClient.SqlCommand
Dim cmdTopic As New Data.SqlClient.SqlCommand 'cmd for 2nd
stored procedure
Dim cmdMedia As New Data.SqlClient.SqlCommand ' 3rd stored
procedure
With cmdALL
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "GetAllTopics"
If DropDownList2.SelectedValue = "-1" Then
.Parameters.AddWithValue("@Type",
DropDownList2.SelectedValue)
End If
.Connection = conn
End With
Dim adapter As New Data.SqlClient.SqlDataAdapter(cmdALL)
With cmdTopic
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "GetByTopic"
If DropDownList3.SelectedIndex 0 Then
.Parameters.AddWithValue("@classificationid",
Integer.Parse(DropDownList2.SelectedValue))
End If
.Connection = conn
End With
Dim adapter As New Data.SqlClient.SqlDataAdapter(cmdTopic)
With cmdMedia
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "GetByMedia"
If DropDownList3.SelectedValue 0 Then
.Parameters.AddWithValue("@Mediaid",
DropDownList3.SelectedValue)
End If
.Connection = conn
End With
Dim adapter As New Data.SqlClient.SqlDataAdapter(cmdMedia)
Try
conn.Open()
Dim ds As New Data.DataSet
adapter.Fill(ds)
GridView1.DataSource = ds
GridView1.DataBind()
Finally
conn.Close()
End Try