我有一个网格视图,它显示了在页面加载事件中预订机票的乘客的详细信息,我有以下代码。
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
我收到此错误:
System.NullReferenceException: Object reference not set to an instance of an object.