table select on form load

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()
 
Im no DB expert, but it looks like you have some multi-line
characters in the connection string, which are taken literally as a
string when enclosed in quotes.

Also, you dont need the concatenation operator (&) to combine
two constant strings (their values are hard-coded).

That being said, try this on for size:
Code:
Dim con_str1 As New OleDbConnection("Provider = Microsft.Jet.OLEDB.4.0;Data Source = C:\data\database.mdb")
 
Code again

This produces the same error.


Dim con_str1 As New OleDbConnection("Provider = Microsft.Jet.OLEDB.4.0;Data Source = C:\data\20304aa1.mdb")
Dim pCmd As New OleDbCommand("SELECT * FROM April", con_str1)
con_str1.Open()
Dim myReader As OleDbDataReader = pCmd.ExecuteReader()
 
My Bad

The connection string was off
man i hate it when you totaly brain spaz lol
sorry people
 
Back
Top