Password Protect an Access Database

Similar documents
22. VB Programming Fundamentals Data Access with Data Objects

Manual Vba Access 2010 Recordset Find

Manual Vba Access 2010 Recordset Findfirst

Create the China Shop Database using Visdata within Visual Basic 6

Manual Vba Access 2007 Recordset Find

The design and implementation of UML-based students information management system

Download, Install and Use Winzip

Visual Basic 6 includes many tools to help you create, revise, manage, and

AIM To analyze, design and develop code for Online Course Reservation System using Rational Rose software

How is information stored?

In this chapter, I m going to show you how to create a working

17. Introduction to Visual Basic Programming

Fundamental Microsoft Jet SQL for Access 2000

Doric Computer Systems International Ltd -

Errors, Warnings, and Issues WARNING #2077

Using the Data Access Controls: DAO & ADO

Real World Foreach Loop Container example

What's the Slope of a Line?

Note : That the code coverage tool is not available for Java CAPS Repository based projects.

EMu Release Notes. ADO Reports. EMu 5.0. Document Version 1

CS Homework 7 p. 1. CS Homework 7. Problem 1 - START THIS A.S.A.P. (in case there are PROBLEMS...)

MITOCW ocw f99-lec07_300k

Manual Vba Access 2010 Close Form Without Saving Record

Remainder Cordial Labeling of Graphs

The Stack, Free Store, and Global Namespace

Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting

Save and Load Searches in Access VBA


Download Beginning ASP.NET E-Commerce In C#: From Novice To Professional (Expert's Voice In.NET) PDF

DOWNLOAD PDF EXCEL MACRO TO PRINT WORKSHEET TO

Slide 1 CS 170 Java Programming 1 Testing Karel

Slide 1 Side Effects Duration: 00:00:53 Advance mode: Auto

Manual Vba Access 2010 Recordset Query

How To Set User Account Password In Windows 7 From Guest

ต วอย างการสร างฟอร ม เมน การใช งาน

Free Downloads Automating Microsoft Access With VBA

PATTERN MAKING FOR THE PHOENIX HOOP

Visual Basic 6.0 Handout 5 Deere & Company

CaseComplete Roadmap

Introduction. Three button technique. "Dynamic Data Grouping" using MS Reporting Services Asif Sayed

Manual Restart Iphone 4s Apple Id Password >>>CLICK HERE<<<

Asset Keeper Pro - Quick Edit. Quick Edit

MITOCW watch?v=4dj1oguwtem

ADO.NET In A Nutshell Download Free (EPUB, PDF)

Microsoft Outlook 2007 Out Of Office Reply To

2: Functions, Equations, and Graphs

Simply Access Tips. Issue April 26 th, Welcome to the twelfth edition of Simply Access Tips for 2007.

Free Downloads Microsoft Access Developer's Guide To SQL Server

Slide 1 CS 170 Java Programming 1

Database Table Editor for Excel. by Brent Larsen

BEGINNER PHP Table of Contents

Lesson 5 Transcript: Client Connectivity

INTERRAI REPOSITORY IS SUPPORTED BY TWO KINDS OF ACCOUNTS AT MICROSOFT

Create your first workbook

Itunes Won T Restore My Ipad 2 Won't Connect

Force.com Workbook. Last updated: May 17, 2010

WINDOWS NT FILE SYSTEM INTERNALS : OSR CLASSIC REPRINTS BY RAJEEV NAGAR

Revisions: jee Initial jee SW Version 1.1 now includes the leave type Other

Lesson 3 Transcript: Part 2 of 2 Tools & Scripting

In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology.

Custom Pattern Tutorial for Photoshop (No Masking Required)

How to Set Up Outlook Express for Railwells

HASH CRACK: PASSWORD CRACKING MANUAL BY JOSHUA PICOLET DOWNLOAD EBOOK : HASH CRACK: PASSWORD CRACKING MANUAL BY JOSHUA PICOLET PDF

I Wish I Knew How To. Program SQLite with Xojo Desktop. By Eugene Dakin. March 2015 Edition (1.2)

Overview of Professional Quest Technologies

When you first launch CrushFTP you may be notified that port 21 is locked. You will be prompted to fix this.

Hyperion System 9 Financial Data Quality Management

ShowMe Guides OpenCart 1.5 User Manual Ebooks Free

Konark - Writing a KONARK Sample Application

Assignment 4: Hashtables

Google Groups. Using, joining, creating, and sharing. content with groups. What's Google Groups? About Google Groups and Google Contacts

Re: Request for Support in JIRA use. 1 of 7 10/6/11 11:35 PM. Hi Bill,

Advanced ASP. Software Engineering Group. Departamento de Lenguajes y Sistemas Informáticos. escuela técnica superior de ingeniería informática

Figure 1-1. When we finish Part 2, our server will be ready to have workstations join the domain and start sharing files. Now here we go!

HELPLINE. Dilwyn Jones

CS193D Handout 10 Winter 2005/2006 January 23, 2006 Pimp Your Classes

Read & Download (PDF Kindle) Data Structures And Other Objects Using Java (4th Edition)

Should I Leave My Macbook Pro On Sleep Or Shutdown

Vlookup for dummies two sheets vlookup

Module 6. Campaign Layering

Ruby on Rails Welcome. Using the exercise files

Genealogy Software. Table of Contents

[FILE] WINDOWS SURFACE HARD RESET

Dreamweaver CS6 For Dummies PDF

My Favorite bash Tips and Tricks

RS BA1 CONNECTION FAILED

How to use IBM/Softlayer Object Storage for Offsite Backup

How I Made $10,000 from Passive Affiliate Income in One Month

How to free book on my ipad. How to free book on my ipad.zip

Karlen Communications

Out for Shopping-Understanding Linear Data Structures English

Mathematical Logic Part One

Hi everyone. I hope everyone had a good Fourth of July. Today we're going to be covering graph search. Now, whenever we bring up graph algorithms, we

Introduction to JavaScript and the Web

[PDF] Database Systems: Design, Implementation, & Management

Cd Manually To Your Hard Drive Without Windows Xp

Running On This Computer

Copy Datatable Schema To Another Datatable Vb.net

Part 1 Simple Arithmetic

! Emacs Howto Tutorial!

Transcription:

Access a Password Protected Microsoft Access Database from within Visual Basic 6 Have you ever wanted to password protect an Access Database that is a Data Store (a repository of Data) used in one of your Visual Basic programs? Password protecting an Access Database is pretty easy, and I'll be showing you how to do that in a minute. Getting to its data from within Visual Basic has been known to be a real pain for beginner programmers---and that's what I want to show you how to do in this article. First though, let's password protect one of my favorite Databases---the China Shop Database. Password Protect an Access Database The first thing we need to do is fire up Access (my screenshots are from Access 97), and select the China Database. With the Database Window in view Select Tools-Security-Set Database Password from the Access Menu Bar http://www.johnsmiley.com/cis18.notfree/smiley002/smiley002.htm (1 of 14)3/28/2004 11:33:34 AM

When you do, the following window will appear Enter a password of your choice (I entered 'dish'---by the way, Access passwords are case sensitive) and click on the OK button (there is no confirmation of any kind). http://www.johnsmiley.com/cis18.notfree/smiley002/smiley002.htm (2 of 14)3/28/2004 11:33:34 AM

By the way, to set a password, you must have the Database opened for Exclusive access, otherwise you'll receive an error message when you try to set the password. Exclusive Mode is the default open mode for a database---when you select the database to be opened from the Access menu bar, the Exclusive checkbox should be selected. That's great---our database is now password protected. If we now close the Database, and then attempt to open it again, we'll be prompted for a password. Enter it (don't forget, Access passwords are case sensitive) and your database will be opened. Open the Database from within Visual Basic Using Data Controls Setting the password in Access is pretty easy. Now let's see how we can get to the Database from within Visual Basic. I want to show you how to open the Database using the Data Control first (both the DAO and ADO Data Control) and then I'll show you how to use Data Objects to open the Database. The DAO Data Control Let's work with a simple table---the Users table has just two fields, so I'll create a form with a VB5 Data Grid and a DAO Data Control. http://www.johnsmiley.com/cis18.notfree/smiley002/smiley002.htm (3 of 14)3/28/2004 11:33:34 AM

Ordinarily, I would set the DatabaseName Property of the Data Control to point to the China Database http://www.johnsmiley.com/cis18.notfree/smiley002/smiley002.htm (4 of 14)3/28/2004 11:33:34 AM

set the RecordSource to the Users Table. However, when I try to select a Table from the RecordSource list, I receive this error message What's the problem? Access wants me to provide a password before it will allow me to select a table from the RecordSource Property (remember, the password we just set in Access is at the Database level---it applies equally to every table in the China Database). What confuses beginners here is that there is no Password Property, so how can we provide one. The answer is the Connect Property. Ordinarily, by default, it just reads Access http://www.johnsmiley.com/cis18.notfree/smiley002/smiley002.htm (5 of 14)3/28/2004 11:33:34 AM

However, for a password protected Database, this is where the password goes. Like this Once we set the Connect Property, a list of tables will appear in the RecordSource http://www.johnsmiley.com/cis18.notfree/smiley002/smiley002.htm (6 of 14)3/28/2004 11:33:34 AM

Property and once we bind the DBGrid to the Data Control by setting its DataSource Property to point to the Data Control http://www.johnsmiley.com/cis18.notfree/smiley002/smiley002.htm (7 of 14)3/28/2004 11:33:34 AM

if we now run the program, we'll see the two records in the User table http://www.johnsmiley.com/cis18.notfree/smiley002/smiley002.htm (8 of 14)3/28/2004 11:33:34 AM

Success! That wasn't too bad was it? We've opened a password protected Access database from within Visual Basic. The ADO Data Control Working with the ADO Data Control is not quite as simple. ADO Data Controls use a Connection String, and for a password protected Database, it should read like this You can't see the full text of the ConnectionString Property, so I've included it below Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\vbfiles\china\china.mdb;Jet OLEDB:Database Password=dish; Notice how the ADO parameter is a little different---it's Database Password not pwd Now we need to specify a RecordSource Property of Users again http://www.johnsmiley.com/cis18.notfree/smiley002/smiley002.htm (9 of 14)3/28/2004 11:33:34 AM

and as we did before, bind the Grid to the Data Control by setting its DataSource Property to point to the Data Control http://www.johnsmiley.com/cis18.notfree/smiley002/smiley002.htm (10 of 14)3/28/2004 11:33:34 AM

If we now run the program, we'll see the two records in the User table What about Data Objects? Some of you may be wondering about working without the Data Control---in other words, by using Data Objects. No problem! Let's look at DAO first. DAO Objects Let's remove the grid and the Data Control from this form, add a ListBox control and a Command Button, and access the Inventory table of the China Database from within Code. (Those of you who have read my Database book will recognize this code form Chapter 9). After we open the China Database, we'll use a SQL statement to list the unique china brand names in the ListBox. In my Database book, we used this code to do the trick Private Sub Command1_Click() http://www.johnsmiley.com/cis18.notfree/smiley002/smiley002.htm (11 of 14)3/28/2004 11:33:34 AM

Dim strsql As String Dim Ws As Workspace Dim Db As Database Dim Rs As Recordset strsql = "SELECT DISTINCT Inventory.Brand FROM Inventory" Set Ws = DBEngine.Workspaces(0) Set Db = Ws.OpenDatabase("c:\vbfiles\china\china.mdb") Set Rs = Db.OpenRecordset(strSQL, dbopendynaset) Do While Not Rs.EOF lstbrands.additem Rs.Fields("Brand").Value Rs.MoveNext Loop End Sub The only problem is this code isn't supplying the password we need to open the China Database. If we place this code in the Click Event Procedure of our Command Button, and then run the program, it bombs with this error message. No problem though---all we need to do is change the line of code that opens the Database Object, like this Set Db = Ws.OpenDatabase("c:\vbfiles\china\china.mdb", False, False, ";pwd=dish") It's a bit cryptic, I know, but essentially all we're doing is supplying a connection string (that's the fourth argument of the DAO OpenDatabase Method. http://www.johnsmiley.com/cis18.notfree/smiley002/smiley002.htm (12 of 14)3/28/2004 11:33:34 AM

If we now run the program, and click on the Command button, you'll see the ListBox is populate with the unique brands from the Inventory table So far, so good. Now let's use ADO to make the connection, and populate the ListBox. Here's the code to do that Private Sub Command1_Click() Dim strsql As String Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Set cn = New ADODB.Connection Set rs = New ADODB.Recordset strsql = "SELECT DISTINCT Inventory.Brand FROM Inventory" cn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\vbfiles\china\china. mdb;jet OLEDB:Database Password=dish;" rs.open strsql, cn, adopenforwardonly, adlockreadonly, adcmdtext Do While Not rs.eof lstbrands.additem rs.fields("brand").value rs.movenext Loop http://www.johnsmiley.com/cis18.notfree/smiley002/smiley002.htm (13 of 14)3/28/2004 11:33:34 AM

End Sub Perhaps even more cryptic than the DAO version, this code uses the ADO Connection and Recordset Objects to open the China Database and, by using a SQL statement, creates a Recordset consisting of unique brand names. If we now run the program, and click on the Command button, once again you'll see the ListBox is populated with the unique brands from the Inventory table Summary I hope you now have the confidence to password protect your Databases! http://www.johnsmiley.com/cis18.notfree/smiley002/smiley002.htm (14 of 14)3/28/2004 11:33:34 AM