September 2003
Intermediate to advanced
624 pages
14h 27m
English
You want to connect to a Microsoft Access database that has been secured with user-level security and a workgroup file.
Use the Jet OLEDB:System Database attribute in the
connection string to specify the path and filename of the workgroup
information file or system database.
The sample code contains a single event handler:
Button.ClickCreates and opens a connection to a Microsoft Access
database secured with user-level security and a workgroup file using
the OLE DB .NET data provider. Information about the database is
displayed from the properties of the
OleDbConnection object.
The C# code is shown in Example 1-4.
Example 1-4. File: AccessSecureForm.cs
// Namespaces, variables, and constants using System; using System.Configuration; using System.Text; using System.Data.OleDb; // . . . private void connectButton_Click(object sender, System.EventArgs e) { StringBuilder result = new StringBuilder( ); // Build the connection string with security information. String connectionString = ConfigurationSettings.AppSettings["MsAccess_ConnectString"] + @"Jet OLEDB:System database=" + ConfigurationSettings.AppSettings["MsAccess_SecureMdw_Filename"] + ";" + "User ID=" + userIdTextBox.Text + ";" + "Password=" + passwordTextBox.Text + ";" + Environment.NewLine + Environment.NewLine; result.Append(connectionString); // Create the connection. OleDbConnection conn = new OleDbConnection(connectionString); try { // Attempt to open ...Read now
Unlock full access