Protected Sub subdata(ByVal id As Integer)
Dim myDataReader As System.Data.SqlClient.SqlDataReader
Dim myConnection As New SqlConnection
Dim myCommand As New SqlCommand
Dim strSQL As String
strSQL = "SELECT class_id,subject_id,subject_name FROM subject where subject_id =@class_id "
myConnection = New SqlConnection(" Data Source=SAJJAD;Initial Catalog=ac;Integrated Security=True")
myCommand.Parameters.AddWithValue("@class_id", id)
myCommand = New SqlCommand(strSQL, myConnection)
myConnection.Open()
myDataReader = myCommand.ExecuteReader()
If myDataReader.HasRows Then
Me.class_DropDownList1.DataSource = myDataReader
Me.sub_DropDownList1.DataValueField = "subject_id"
sub_DropDownList1.DataTextField = "subject_name"
sub_DropDownList1.DataBind()
End If
myDataReader.Close()
myConnection.Close()
End Sub
from above code i want to populate the dropdownlist list with getting the value from parameter but i am facing this error
(Must declare the scalar variable "@class_id")
what should i do