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. General Programming
  3. C#
  4. OLE DB problem

OLE DB problem

Scheduled Pinned Locked Moved C#
databasecomhelp
6 Posts 3 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.
  • T Offline
    T Offline
    Tyrus182
    wrote on last edited by
    #1

    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

    S 1 Reply Last reply
    0
    • T Tyrus182

      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

      S Offline
      S Offline
      Sean89
      wrote on last edited by
      #2

      What is the error you are getting? Wacky waving inflateable arm flailing tube man! - Family Guy

      T 1 Reply Last reply
      0
      • S Sean89

        What is the error you are getting? Wacky waving inflateable arm flailing tube man! - Family Guy

        T Offline
        T Offline
        Tyrus182
        wrote on last edited by
        #3

        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 :)

        S 1 Reply Last reply
        0
        • T Tyrus182

          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 :)

          S Offline
          S Offline
          Sean89
          wrote on last edited by
          #4

          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

          T 1 Reply Last reply
          0
          • S Sean89

            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

            T Offline
            T Offline
            Tyrus182
            wrote on last edited by
            #5

            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.

            D 1 Reply Last reply
            0
            • T Tyrus182

              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.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              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

              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