Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / November 2006

Tip: Looking for answers? Try searching our database.

Open MS Acess with password protected in c#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
-xx- - 24 Nov 2006 00:10 GMT
Hi,

I am new to c# and just trying out c# with ms access.  First problem i
encountered is how do i open up ms access that has password.

Here is my current codes which working fine if there is no password on ms
access:

//Specify sql server-specific connection string
private const string strdns = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=f:\sample1.mdb";

//Main connector
public OleDbConnection thisconnection;

public clsDBBasic()
{
//Open the database
try
{
thisconnection = new OleDbConnection(strdns);
thisconnection.Open();
}
catch
{
throw new Exception("Open data error.");
}
}

Can anyone please tell me how to open ms access with password protected? I
have tried change the STRDNS variabale to

private const string strdns = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=f:\sample1.mdb;ID=sa;PWD=abc123;Persist Security Info=true";  //Not
working

private const string strdns = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=f:\sample1.mdb;OLEDB Password=abc123"; //Not working
Mark Rae - 24 Nov 2006 00:37 GMT
> Can anyone please tell me how to open ms access with password protected? I
> have tried change the STRDNS variabale to
[quoted text clipped - 5 lines]
> private const string strdns = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=f:\sample1.mdb;OLEDB Password=abc123"; //Not working

private const string strdns = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=f:\sample1.mdb;Jet OLEDB:Database Password=abc123;"
beaker - 25 Nov 2006 09:33 GMT
>>Can anyone please tell me how to open ms access with password protected? I
>>have tried change the STRDNS variabale to
[quoted text clipped - 8 lines]
> private const string strdns = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=f:\sample1.mdb;Jet OLEDB:Database Password=abc123;"

I was about to ask the very same question!

Is the only way to tell if the DB is password protected to catch the
exception thrown by Open() and check the message for 'Not a valid
password'?  Just seems a bit untidy to me.

Thanks,

Gary
RobinS - 24 Nov 2006 07:24 GMT
Here's my connection string for connecting to an Access
database that has a database password. Sorry, this is VB,
but I think you can just change the & to + to do C#.

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\MyDatabase.mdb;" & _
"Persist Security Info=False;Jet OLEDB:Database Password=mypassword"

Robin S.
---------------------------------------

> Hi,
>
[quoted text clipped - 34 lines]
> private const string strdns = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=f:\sample1.mdb;OLEDB Password=abc123"; //Not working

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.