473,700 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open MS Acess with password protected in c#

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=Micr osoft.Jet.OLEDB .4.0;Data
Source=f:\sampl e1.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=Micr osoft.Jet.OLEDB .4.0;Data
Source=f:\sampl e1.mdb;ID=sa;PW D=abc123;Persis t Security Info=true"; //Not
working

private const string strdns = @"Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=f:\sampl e1.mdb;OLEDB Password=abc123 "; //Not working
Nov 23 '06 #1
3 3809
"-xx-" <kh**********@y ahoo.comwrote in message
news:eC******** ******@TK2MSFTN GP06.phx.gbl...
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=Micr osoft.Jet.OLEDB .4.0;Data
Source=f:\sampl e1.mdb;ID=sa;PW D=abc123;Persis t Security Info=true"; //Not
working

private const string strdns = @"Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=f:\sampl e1.mdb;OLEDB Password=abc123 "; //Not working
private const string strdns = @"Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=f:\sampl e1.mdb;Jet OLEDB:Database Password=abc123 ;"
Nov 24 '06 #2
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=Micro soft.Jet.OLEDB. 4.0;Data Source=E:\MyDat abase.mdb;" & _
"Persist Security Info=False;Jet OLEDB:Database Password=mypass word"

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

"-xx-" <kh**********@y ahoo.comwrote in message
news:eC******** ******@TK2MSFTN GP06.phx.gbl...
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=Micr osoft.Jet.OLEDB .4.0;Data
Source=f:\sampl e1.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=Micr osoft.Jet.OLEDB .4.0;Data
Source=f:\sampl e1.mdb;ID=sa;PW D=abc123;Persis t Security Info=true"; //Not
working

private const string strdns = @"Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=f:\sampl e1.mdb;OLEDB Password=abc123 "; //Not working


Nov 24 '06 #3
Mark Rae wrote:
"-xx-" <kh**********@y ahoo.comwrote in message
news:eC******** ******@TK2MSFTN GP06.phx.gbl...

>>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=Micr osoft.Jet.OLEDB .4.0;Data
Source=f:\sam ple1.mdb;ID=sa; PWD=abc123;Pers ist Security Info=true"; //Not
working

private const string strdns = @"Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=f:\sam ple1.mdb;OLEDB Password=abc123 "; //Not working


private const string strdns = @"Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=f:\sampl e1.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
Nov 25 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
25258
by: Geert-Pieter Hof | last post by:
Hello, My VB 6.0 application read and writes data from and to a MS Excel workbook, using the Microsoft.Jet.OLEDB.4.0 provider. Now I want to protect the Excel workbook with a password, but I figured out that it is not possible to open the workbook for data access with ADO (http://support.microsoft.com/?KBID=211378). Is there another way to use a password protected Excel workbook in my
4
1594
by: Edward | last post by:
My client has a database that was written in Access97. The database is password protected. If I try to open the database by double-clicking on it, it asks for the password. In Access97, I can enter the password and open the database. Similarly in Access 2003. But not in Access 2000 - I get a "Not a valid password" error.
4
2759
by: connoisseur.infotech | last post by:
hello we are developing one tool where we need to open and make password protected zip files. we found some solutions but they don't support password protected things. does any one knows about this or any aproach for this.
0
1364
by: sonicpulse | last post by:
Hello, I made a program that iterates through all the pdf's in a folder and opens them and prints them. However, all of these pdf's are password protected, so I have to manually type in the password many times. Is there any way to open a password-protected PDF with the password entered through python? Thanks
0
1576
by: guptasourav | last post by:
I am opening an Excel file on my server, and saving it with some other name and then trying to coping the new excel to my local machine. If i use a simple Excel(without macro but with password) it works properly but if i use a macro and make the excel password protected then it does not allow me to open it. It does not give any exception but on reaching to "oWB = oXL.Workbooks.Open(" it hangs up. Private Sub Page_Load(ByVal sender As...
1
1234
by: jayakumarmaarga | last post by:
Hi, How to open Password Protected Excelsheet, I know password and i want to open that excelsheet by given this password and read the excelsheet values again post values to sql database.
2
5278
by: veer | last post by:
Hi i want to open excel file using vb.net . The file is passsword protected and i know the password when i used to open the file with out password it works fine and open but when the file with password protected file came it shows the error "File can't be decrypt" sconnectionstring ="Provider=Microsoft.jet.oledb.4.0;data source=c:\new.xls;Extended Properties=excel8.0; please tell me how can i open the password protected excel file
1
1251
by: denniswong288 | last post by:
Hi, My website has PDF documents that's available for registered users to view online (through my site) only. Currently, I can't find any solutions to prevent users from downloading/"save-as" the PDF doc in their local drives, so I'm thinking of password-protecting these PDFs. This will ensure that they'd not be able to view the PDFs even though they download it and save-as local. However, how do I open these password-protected PDFs...
0
2302
by: itshibu | last post by:
I tried to write a program that can open files from the server. But the shared folder in the Win2003 server is password protected. i tried the following code System.Diagnostics.Process.Start("net.exe", "use K: \\Server\URI\path\here /USER:username password" ) Dim p = New System.Diagnostics.Process p.Start("k:\" & Filename) System.Diagnostics.Process.Start("net.exe", "use /delete K:" ) And it is working fine. But for big files and...
0
8647
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9217
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9076
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8926
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6563
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5903
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4659
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2392
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.