database location
-
this.oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=c:\Technomedia.mdb;Mode=ReadWrite|Share Deny None;" for the source, how do I make it so it accesses the database that is in the same folder as the program? Because when I load the program on other computer it give me this exception error: "Process id = 0x4f4(1268), Thead id = 0x5dc(1500)" I think it gives me this because it can't find the database because it is hardcoded into the program as being in a different location. So I want to know how to make it look for the database in the program location. i tried Data Source=technomedia.mdb but it gives me an error. Thanks
-
this.oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=c:\Technomedia.mdb;Mode=ReadWrite|Share Deny None;" for the source, how do I make it so it accesses the database that is in the same folder as the program? Because when I load the program on other computer it give me this exception error: "Process id = 0x4f4(1268), Thead id = 0x5dc(1500)" I think it gives me this because it can't find the database because it is hardcoded into the program as being in a different location. So I want to know how to make it look for the database in the program location. i tried Data Source=technomedia.mdb but it gives me an error. Thanks
Does this work? What exception is thrown, if not?
oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Password=\"\";User ID=Admin;Data Source=" + Environment.CurrentDirectory + "\\Technomedia.mdb;Mode=ReadWrite|Share Deny None;"
-
Does this work? What exception is thrown, if not?
oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Password=\"\";User ID=Admin;Data Source=" + Environment.CurrentDirectory + "\\Technomedia.mdb;Mode=ReadWrite|Share Deny None;"
-
now it gets stuck on my dataadapter, give me this: An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll on this line: oleDbDataAdapter3.Fill(dataSet1, "Region");
Please post the full stack trace. (You should always do this when you post a question; it'll speed things up a bit.)
-
Please post the full stack trace. (You should always do this when you post a question; it'll speed things up a bit.)
-
I am just started with c# and do it as a hoby. So I have no idea what a full stack trace is. Thanks
Okay, I didn't notice that it was an unhandled exception. The first thing you need to do is wrap that section of code in a try-catch block so you can catch the exception! When an exception is "unhandled", that means that it's bubbled up to the top, causing your program to crash. You will do something like this:
try {
// ... your code that's throwing the exception; following is a line that throws one on purpose
throw new ApplicationException("I'm a little teapot");
} catch (Exception e) {
Console.WriteLine(e.StackTrace);
}You should read up on exception handling right away-- you're already past the "Hello, world!" stage, and into database applications, where you really need to be able to clean up your resources in case of a problem. Good luck.
-
Okay, I didn't notice that it was an unhandled exception. The first thing you need to do is wrap that section of code in a try-catch block so you can catch the exception! When an exception is "unhandled", that means that it's bubbled up to the top, causing your program to crash. You will do something like this:
try {
// ... your code that's throwing the exception; following is a line that throws one on purpose
throw new ApplicationException("I'm a little teapot");
} catch (Exception e) {
Console.WriteLine(e.StackTrace);
}You should read up on exception handling right away-- you're already past the "Hello, world!" stage, and into database applications, where you really need to be able to clean up your resources in case of a problem. Good luck.
this is what I get at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) at System.Data.OleDb.OleDbConnection.InitializeProvider() at System.Data.OleDb.OleDbConnection.Open() at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) at System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) at WindowsApplication5.Form1..ctor() in c:\documents and settings\roman\my documents\visual studio projects\windowsapplication5\form1.cs:line 77
-
this is what I get at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) at System.Data.OleDb.OleDbConnection.InitializeProvider() at System.Data.OleDb.OleDbConnection.Open() at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) at System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) at WindowsApplication5.Form1..ctor() in c:\documents and settings\roman\my documents\visual studio projects\windowsapplication5\form1.cs:line 77
Try creating an ODBC data source, and then use the data source name in your connection string.
-
Try creating an ODBC data source, and then use the data source name in your connection string.