L
Len
Help. I am new to VB.NET 2003. I have written an application for SQL
CE (also new at) and I am very frustrated. This is the code:
strSQL = "INSERT INTO ROLL(RNO, SPCD, UPDATES, CONTIME, STCD,
PSCD, LOCD) " & _
"VALUES('" & strPrevRoll & "', '" & strSpeed & "', 0, '" &
datCurrent & "', '" & strStatus & "', '" & strPosition & "', " &
intLocation & ")"
cmd.CommandText = strSQL
cmd.Connection = Conn
cmd.ExecuteNonQuery()
strSQL = "SELECT * from ROLL WHERE RNO = '" & strRoll
& "'"
cmd.CommandText = strSQL
cmd.Connection = Conn
reader = cmd.ExecuteReader
While reader.Read
cmbPosition.Text = reader.Item("PSCD")
cmbStatus.Text = reader.Item("STCD")
cmbSpeed.Text = reader.Item("SPCD")
If cmbStatus.Text = "S1 " Then
cmbPosition.Visible = False
lblPosition.Visible = False
lblPOS.Visible = False
End If
End While
'Conn.Close()
'Conn.Open()
'reader.Close()
'txtScan.Focus()
Everything works find until the "While reader.Read" line is executed
for the second time. It does not find more than one record, and the
very next line I get the error :
An unhandled exception of type 'System.InvalidOperationException'
occurred in System.Data.SqlServerCe.dll
Additional information: Invalid attempt to Read when reader is closed.
I have tried several things as you can see in the commented out lines.
Regardless of what line after the "End While", I get the error. HELP
Please. Thanks in advance.
Len
CE (also new at) and I am very frustrated. This is the code:
strSQL = "INSERT INTO ROLL(RNO, SPCD, UPDATES, CONTIME, STCD,
PSCD, LOCD) " & _
"VALUES('" & strPrevRoll & "', '" & strSpeed & "', 0, '" &
datCurrent & "', '" & strStatus & "', '" & strPosition & "', " &
intLocation & ")"
cmd.CommandText = strSQL
cmd.Connection = Conn
cmd.ExecuteNonQuery()
strSQL = "SELECT * from ROLL WHERE RNO = '" & strRoll
& "'"
cmd.CommandText = strSQL
cmd.Connection = Conn
reader = cmd.ExecuteReader
While reader.Read
cmbPosition.Text = reader.Item("PSCD")
cmbStatus.Text = reader.Item("STCD")
cmbSpeed.Text = reader.Item("SPCD")
If cmbStatus.Text = "S1 " Then
cmbPosition.Visible = False
lblPosition.Visible = False
lblPOS.Visible = False
End If
End While
'Conn.Close()
'Conn.Open()
'reader.Close()
'txtScan.Focus()
Everything works find until the "While reader.Read" line is executed
for the second time. It does not find more than one record, and the
very next line I get the error :
An unhandled exception of type 'System.InvalidOperationException'
occurred in System.Data.SqlServerCe.dll
Additional information: Invalid attempt to Read when reader is closed.
I have tried several things as you can see in the commented out lines.
Regardless of what line after the "End While", I get the error. HELP
Please. Thanks in advance.
Len