OLE DB problem
-
Hello i have a program that is using oledb stuff and it has an openfile dialog whenever i go in the openfile dialog and select a file anytime after that a oledb object gets called the program crashes why is openfile dialog affecting my database classes. the open file does nothing but return a string to my program
-
Hello i have a program that is using oledb stuff and it has an openfile dialog whenever i go in the openfile dialog and select a file anytime after that a oledb object gets called the program crashes why is openfile dialog affecting my database classes. the open file does nothing but return a string to my program
-
What is the error you are getting? Wacky waving inflateable arm flailing tube man! - Family Guy
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll "System.Data.OleDb.OleDbException: Could not find file 'D:\\AttendanceDB.mdb'.\r\n at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)\r\n at System.Data.OleDb.OleDbConnection.InitializeProvider()\r\n at System.Data.OleDb.OleDbConnection.Open()\r\n at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)\r\n at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)\r\n at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)\r\n at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)\r\n at SanMarCalendar.SanMar.cmbGroups_SelectedIndexChanged(Object sender, EventArgs e) in d:\\sanmar\\sanmarcalendar\\forms\\sanmar.cs:line 1338" i never even told it to set it to that file or any other file the proper location of the file is set by default to ../../AttendanceDB.mdb but for some reason whenever i use an openfile dialog it sets it to the above. and gives me this exception why is openfile dialog changing my oledbConnection string :)
-
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll "System.Data.OleDb.OleDbException: Could not find file 'D:\\AttendanceDB.mdb'.\r\n at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)\r\n at System.Data.OleDb.OleDbConnection.InitializeProvider()\r\n at System.Data.OleDb.OleDbConnection.Open()\r\n at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)\r\n at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)\r\n at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)\r\n at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)\r\n at SanMarCalendar.SanMar.cmbGroups_SelectedIndexChanged(Object sender, EventArgs e) in d:\\sanmar\\sanmarcalendar\\forms\\sanmar.cs:line 1338" i never even told it to set it to that file or any other file the proper location of the file is set by default to ../../AttendanceDB.mdb but for some reason whenever i use an openfile dialog it sets it to the above. and gives me this exception why is openfile dialog changing my oledbConnection string :)
Have you tried giving the connection string the entire physical path of the DB just to see if it still does it? Mabey you could try changing the path so something like:
Application.StartupPath() + "\AttendanceDB.mdb";
and see if it still gives you the error. Wacky waving inflateable arm flailing tube man! - Family Guy
-
Have you tried giving the connection string the entire physical path of the DB just to see if it still does it? Mabey you could try changing the path so something like:
Application.StartupPath() + "\AttendanceDB.mdb";
and see if it still gives you the error. Wacky waving inflateable arm flailing tube man! - Family Guy
the connections all work fine untill i open the open file dialog then they all die once i try to use them after the open file dialog it actualy looks like whenever i call fill on an adapter it dies after the open file dialog the open file dialog has nothing to do with the database stuff.
-
the connections all work fine untill i open the open file dialog then they all die once i try to use them after the open file dialog it actualy looks like whenever i call fill on an adapter it dies after the open file dialog the open file dialog has nothing to do with the database stuff.
This is more-than-likely because your connection string isn't specifying a complete path to your database, something like "DataSource=mydata.mdb". Since you left out the fully qualified path, it is assumed that the database is in the current directory. The OpenFile dialog will change the current directory to whatever was picked in the dialog, thereby breaking the path to your database. ALWAYS use fully qualified paths when working with any kind of files.
string dbPath = Path.Combine(Application.StartupPath, "myData.mdb");
string connString = String.Format("blah;DataSource={0};", dbPath);RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome