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. Acces Database: Password Protected

Acces Database: Password Protected

Scheduled Pinned Locked Moved C#
csharpdatabasehelptutorialquestion
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.
  • K Offline
    K Offline
    Ken Mazaika
    wrote on last edited by
    #1

    Hi I'm looking to my queries to an Access database in C# that is password protected and I am having difficulties. The password is 13 characters long and contains capital, lowercase, symbols (#$%^) and numbers. My connection string looks like this: "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.mdb;User ID=admin;Password=P@$$w0rD"; When I call: OleDbConnection myConnection = new OleDbConnection(connectionString); myConnection.Open(); The program crashes with an unhandled exception of type 'System.Data.OleDb.OleDbException in system.data.dll. I did some research and it says that C# handles special characters in a way that isn't compatible with some access databases. I'm not sure if $%^ are special characters, or if that means just unicode. Does anyone know where I'm slipping up or how to fix this? Any advice would be appreciated.

    C M K 3 Replies Last reply
    0
    • K Ken Mazaika

      Hi I'm looking to my queries to an Access database in C# that is password protected and I am having difficulties. The password is 13 characters long and contains capital, lowercase, symbols (#$%^) and numbers. My connection string looks like this: "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.mdb;User ID=admin;Password=P@$$w0rD"; When I call: OleDbConnection myConnection = new OleDbConnection(connectionString); myConnection.Open(); The program crashes with an unhandled exception of type 'System.Data.OleDb.OleDbException in system.data.dll. I did some research and it says that C# handles special characters in a way that isn't compatible with some access databases. I'm not sure if $%^ are special characters, or if that means just unicode. Does anyone know where I'm slipping up or how to fix this? Any advice would be appreciated.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Ken Mazaika wrote:

      The program crashes with an unhandled exception of type 'System.Data.OleDb.OleDbException in system.data.dll.

      And what did the exception message say? That is quite important becuase there are many reasons it might throw an exception of that type.


      Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." My website

      K 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Ken Mazaika wrote:

        The program crashes with an unhandled exception of type 'System.Data.OleDb.OleDbException in system.data.dll.

        And what did the exception message say? That is quite important becuase there are many reasons it might throw an exception of that type.


        Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." My website

        K Offline
        K Offline
        Ken Mazaika
        wrote on last edited by
        #3

        The message box said "Microsoft Development Environment" in the titlebar, the words "An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll" and Break, Continue, Ignore (disabled), and Help buttons. The debugger highlights the line immediately following the Open(), which happens to be return true; thanks, -Ken

        1 Reply Last reply
        0
        • K Ken Mazaika

          Hi I'm looking to my queries to an Access database in C# that is password protected and I am having difficulties. The password is 13 characters long and contains capital, lowercase, symbols (#$%^) and numbers. My connection string looks like this: "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.mdb;User ID=admin;Password=P@$$w0rD"; When I call: OleDbConnection myConnection = new OleDbConnection(connectionString); myConnection.Open(); The program crashes with an unhandled exception of type 'System.Data.OleDb.OleDbException in system.data.dll. I did some research and it says that C# handles special characters in a way that isn't compatible with some access databases. I'm not sure if $%^ are special characters, or if that means just unicode. Does anyone know where I'm slipping up or how to fix this? Any advice would be appreciated.

          M Offline
          M Offline
          Michael Potter
          wrote on last edited by
          #4

          Just to eliminate an obvious error: I am assuming you are using the @ symbol at the beginning of your connection string assignment. string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.mdb;User ID=admin; Password=P@$$w0rD"; If not, then you should be using a double backslash when listing your Source:

          Source=C:\\file.mdb;
          
          K 1 Reply Last reply
          0
          • M Michael Potter

            Just to eliminate an obvious error: I am assuming you are using the @ symbol at the beginning of your connection string assignment. string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.mdb;User ID=admin; Password=P@$$w0rD"; If not, then you should be using a double backslash when listing your Source:

            Source=C:\\file.mdb;
            
            K Offline
            K Offline
            Ken Mazaika
            wrote on last edited by
            #5

            Sorry, I did use a double backslash I just changed the code to a different path to be simpler. Thanks though, -Ken

            1 Reply Last reply
            0
            • K Ken Mazaika

              Hi I'm looking to my queries to an Access database in C# that is password protected and I am having difficulties. The password is 13 characters long and contains capital, lowercase, symbols (#$%^) and numbers. My connection string looks like this: "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.mdb;User ID=admin;Password=P@$$w0rD"; When I call: OleDbConnection myConnection = new OleDbConnection(connectionString); myConnection.Open(); The program crashes with an unhandled exception of type 'System.Data.OleDb.OleDbException in system.data.dll. I did some research and it says that C# handles special characters in a way that isn't compatible with some access databases. I'm not sure if $%^ are special characters, or if that means just unicode. Does anyone know where I'm slipping up or how to fix this? Any advice would be appreciated.

              K Offline
              K Offline
              Ken Mazaika
              wrote on last edited by
              #6

              I figured out the answer thanks to another user's post on a particular article here. To access a password protected database you can add another part to the connection string. I added this to the end of it and it works like a charm. jet OLEDB:Database Password=mypassword; I'm not sure why the password needs to be listed twice, but it seems to work. I also had issues doing this with Toolbox>Data>OleDbConnection wizard that matched my results pretty well. Hardcoding the connection string with that added fixes it though. -Ken

              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