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. Database Directory Error

Database Directory Error

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

    I noticed a problem with this program I made. It basically just opens database files using the OleDbDataAdapter, and for some odd reason, it cannot open database files that are outside of its own directory. For example, if the project is in D:\project, and the database file is in D:\project\database.csv. It will work, but on the other hand if the database file is in C:\database.csv, it will not open it. I was wondering if anyone could help me with this. Here is my code: oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dir + @";Extended Properties=""text;HDR=Yes;FMT=Delimited"""; oleDbConnection1.Open(); // where the variable dir is the datasource

    K 1 Reply Last reply
    0
    • T TheMajorRager

      I noticed a problem with this program I made. It basically just opens database files using the OleDbDataAdapter, and for some odd reason, it cannot open database files that are outside of its own directory. For example, if the project is in D:\project, and the database file is in D:\project\database.csv. It will work, but on the other hand if the database file is in C:\database.csv, it will not open it. I was wondering if anyone could help me with this. Here is my code: oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dir + @";Extended Properties=""text;HDR=Yes;FMT=Delimited"""; oleDbConnection1.Open(); // where the variable dir is the datasource

      K Offline
      K Offline
      KaptinKrunch
      wrote on last edited by
      #2

      The way to make this work is as follows string dir = @"C:\database.csv" or string dir = @"\\myremotepc\sharefolder\database.csv" oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dir";Extended Properties=""text;HDR=Yes;FMT=Delimited""";

      T 1 Reply Last reply
      0
      • K KaptinKrunch

        The way to make this work is as follows string dir = @"C:\database.csv" or string dir = @"\\myremotepc\sharefolder\database.csv" oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dir";Extended Properties=""text;HDR=Yes;FMT=Delimited""";

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

        Thanks for your reply, it turned out it was whitespace. I had whitespace in my connection string. That is why it was crashing. Sincerely, The Major Rager

        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