473,750 Members | 2,559 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 3814
"-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
25263
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
1595
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
2760
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
1365
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
1580
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
1235
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
5282
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
1255
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
2306
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
9001
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8839
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
9584
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
9257
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...
0
8265
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6811
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
4716
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2227
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.