Hello Guys, first ive got an error saying
"There is already an open DataReader associated with this Command which must be closed first"
So I change my code I close the first reader soo here is my code now
If (IsPostBack = False) Then
Dim strSQL As String
Dim strSQL2 As String
Dim SQLreader As SqlClient.SqlDataReader
Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection("Data Source=ML0003135586;Initial Catalog=TestSQL;Integrated Security=True")
strSQL = "SELECT [ID], [CourseTitle], [CourseCode], [Objectives], [Duration] FROM [tblTrainingPlan]WHERE ([Category] = @Category)"
connection.Open()
Dim myCommand As SqlClient.SqlCommand = New SqlClient.SqlCommand(strSQL, connection)
myCommand.Parameters.AddWithValue("@Category", lblGEE.Text)
SQLreader = myCommand.ExecuteReader()
SQLreader = GridView1.DataSource
GridView1.DataBind()
SQLreader.Close()
strSQL2 = "SELECT [ID], [CourseTitle], [CourseCode], [Objectives], [Duration] FROM [tblTrainingPlan]WHERE ([Category] = @Category)"
Dim myCommand2 As SqlClient.SqlCommand = New SqlClient.SqlCommand(strSQL2, connection)
myCommand2.Parameters.AddWithValue("@Category", lblCross.Text)
TPCross.DataSource = myCommand2.ExecuteReader()
TPCross.DataBind()
connection.Close()
connection.Close()
End If
My problem is when i run it new error occured saying
Object reference not set to an instance of an object.
Help plss I dont know where ive got wrong.. Keep banging my head just to solved this problem.
Thanks in advance and more programming to come ^_^