I have a gridview which shows the details of passenger who have booked their ticket on page load event i have following code.
Label1.Text = Session("Pid").ToString()
Dim Sql As String = "select * from Plist where Pid='" & Label1.Text & "'"
Try
con.ConnectionString = strCon
Dim cm As New SqlClient.SqlCommand(Sql, con)
con.Open()
cm.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
I am getting this error:
System.NullReferenceException: Object reference not set to an instance of an object.