archer_coal Posted April 4, 2003 Posted April 4, 2003 I'm trying to have my form load a table depending on the date, much like a calendar. I'm 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() Quote
*Experts* Nerseus Posted April 4, 2003 *Experts* Posted April 4, 2003 Is there supposed to be an underscore in the Data Source part of your connection string? -nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
*Experts* Bucky Posted April 4, 2003 *Experts* Posted April 4, 2003 I'm 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 don't need the concatenation operator (&) to combine two constant strings (their values are hard-coded). That being said, try this on for size: Dim con_str1 As New OleDbConnection("Provider = Microsft.Jet.OLEDB.4.0;Data Source = C:\data\database.mdb") Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
archer_coal Posted April 4, 2003 Author Posted April 4, 2003 no that was mistakenly put there becuse of the window spacing Quote
*Experts* Bucky Posted April 4, 2003 *Experts* Posted April 4, 2003 So, did that solve your problem? :confused: Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
archer_coal Posted April 4, 2003 Author Posted April 4, 2003 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() Quote
archer_coal Posted April 4, 2003 Author Posted April 4, 2003 My Bad The connection string was off man i hate it when you totaly brain spaz lol sorry people Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.