Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. database location

database location

Scheduled Pinned Locked Moved Database
questiondatabasehelptutorial
9 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • A Anonymous

      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

      J Offline
      J Offline
      Jeff Varszegi
      wrote on last edited by
      #2

      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;"

      A 1 Reply Last reply
      0
      • J Jeff Varszegi

        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;"

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        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");

        J 1 Reply Last reply
        0
        • A Anonymous

          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");

          J Offline
          J Offline
          Jeff Varszegi
          wrote on last edited by
          #4

          Please post the full stack trace. (You should always do this when you post a question; it'll speed things up a bit.)

          A 1 Reply Last reply
          0
          • J Jeff Varszegi

            Please post the full stack trace. (You should always do this when you post a question; it'll speed things up a bit.)

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            I am just started with c# and do it as a hoby. So I have no idea what a full stack trace is. Thanks

            J 1 Reply Last reply
            0
            • A Anonymous

              I am just started with c# and do it as a hoby. So I have no idea what a full stack trace is. Thanks

              J Offline
              J Offline
              Jeff Varszegi
              wrote on last edited by
              #6

              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.

              A 1 Reply Last reply
              0
              • J Jeff Varszegi

                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.

                A Offline
                A Offline
                Anonymous
                wrote on last edited by
                #7

                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

                J 1 Reply Last reply
                0
                • A Anonymous

                  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

                  J Offline
                  J Offline
                  Jeff Varszegi
                  wrote on last edited by
                  #8

                  Try creating an ODBC data source, and then use the data source name in your connection string.

                  A 1 Reply Last reply
                  0
                  • J Jeff Varszegi

                    Try creating an ODBC data source, and then use the data source name in your connection string.

                    A Offline
                    A Offline
                    Anonymous
                    wrote on last edited by
                    #9

                    will try, Thanks

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups