Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,
I have a problem and i need your support.
I need C#.net software and need connection MSAccess 2003 database "mdb" with security from "file working group"(mdw).
my code is:

C#
OleDbConnectionStringBuilder csbOLE = new OleDbConnectionStringBuilder();
csbOLE.Provider = "Microsoft.Jet.OLEDB.4.0";
csbOLE.DataSource = @"C:\MyBase.mdb";
csbOLE.Add("Jet OLEDB:System Database", @"C:\MySYSBase.mdw");
csbOLE.Add("Jet OLEDB:User ID", "Admin");
csbOLE.Add("Jet OLEDB:Password", "*");
OleDbConnection conOLE = new OleDbConnection(csbOLE.ConnectionString);
conOLE.Open; //<== this occurs error 


on line conOLE.Open an error occurs: -2147217843 "Not a valid account name or password."

What I have tried:

User "Admin" is owner of MyBase.mdb and have ALL permissions in this base. Password "*" is true. Opening this base in Application MSAccess is true (with this user and his password).

Please tell me where I am wrong. Big Thanks!!!
Posted
Updated 7-Jul-22 2:46am

1 solution

Have a look at the resulting connection string - which should look like this
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Mybase.mdb;Jet OLEDB:System Database=C:\MySysBase.mdw;User ID=Admin;Password=*;
I.e. without the "Jet OLEDB:" bit on the password. See reference Access connection strings - ConnectionStrings.com[^]

BTW It's very unusual to store files in the root folder of C: - I strongly advise you to use a specific folder, or ProgramData folder etc.
 
Share this answer
 
v2
Comments
DimA__B2 8-Jul-22 0:30am    
Big thanks, my friend! It's work. You link is very usefull.
I completely agree about the location database files. Folder "C:\" is just for the example in the question. As well username and password. Thank you again so much!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900