仅仅因为(在我的代码中)有些时候看起来sqlDataReader被打开并告诉我“已经有一个打开的数据读取器”
我决定放这一行: If Not SqlReader.IsClosed Then SqlReader.Close()
未设置对象实例的对象变量
Select Case PreviousRecord
Case True
SqlComm = New SqlCommand("Select * from " & tmpName & " where FuelOrderValid = '" & True & "' Order by FuelLoadDate", ReportsSQLConn)
Case False
SqlComm = New SqlCommand("Select * from " & tmpName & " where FuelOrderValid = '" & True & "' And FuelOrderID = '" & ordNum & "' Order by FuelLoadDate", ReportsSQLConn)
End Select
If Not SqlReader.IsClosed Then SqlReader.Close()
If SqlComm.Connection.State = Data.ConnectionState.Open Then
SqlReader = SqlComm.ExecuteReader(CommandBehavior.KeyInfo)
Else
SqlComm.Connection.Open()
SqlReader = SqlComm.ExecuteReader(CommandBehavior.KeyInfo)
End If
但是现在,当它涉及到执行
If Not SqlReader.IsClosed Then SqlReader.Close()
它给出了错误的指令:
Object Variable Not Set To An Instance Of An Object
我实在无法理解WH y正在这样做。
请问有人帮我吗?
你能添加更多的上下文吗? – shaans 2011-03-24 07:50:36
@Shaans:行吗? – 2011-03-24 07:53:09