archer_coal
Well-known member
- Joined
- Apr 4, 2003
- Messages
- 96
Im trying to have my form load a table depending on the date, much like a calendar. Im getting this error An unhandled exception of type System.InvalidOperationException occurred in system.data.dll
Here is the code
Dim con_str1 As New OleDbConnection("Provider =_
Microsft.Jet.OLEDB.4.0;" & "Data Source =_ C:\data\database.mdb")
Dim pCmd As New OleDbCommand("SELECT * FROM TABLE", con_str1)
con_str1.Open()
Dim myReader As OleDbDataReader = pCmd.ExecuteReader()
Try
While myReader.Read()
lbx1.FindString(myReader.GetInt32(0).ToString() + ", " _
+ myReader.GetString(1))
End While
Finally
always call Close when done reading.
myReader.Close()
always call Close when done reading.
con_str1.Close()
End Try
It halts at con_str1.Open()
Here is the code
Dim con_str1 As New OleDbConnection("Provider =_
Microsft.Jet.OLEDB.4.0;" & "Data Source =_ C:\data\database.mdb")
Dim pCmd As New OleDbCommand("SELECT * FROM TABLE", con_str1)
con_str1.Open()
Dim myReader As OleDbDataReader = pCmd.ExecuteReader()
Try
While myReader.Read()
lbx1.FindString(myReader.GetInt32(0).ToString() + ", " _
+ myReader.GetString(1))
End While
Finally
always call Close when done reading.
myReader.Close()
always call Close when done reading.
con_str1.Close()
End Try
It halts at con_str1.Open()