Using the UDL Wizard to create an OLE DB connection string
Note If you add a user ID and a password in an ASP file, anyone who
has access to the source file on the server can read this information.
Therefore, you may want to take the following additional precautions:
� | Use Microsoft Windows Integrated authentication to
Microsoft SQL server when applicable. |
� | Create the connection string in a .dll file, and then call
the .dll file from your ASP page.
For more
information, click the following article number to view the article in the
Microsoft Knowledge Base: 271284
How to access the COM+ object constructor string in a Visual Basic component
|
� | Keep the system updated by applying all security updates,
and hotfixes. |
� | Make sure that your server that is running Microsoft
Internet Information Services (IIS) or Internet Information Server (IIS) is
secure to reduce the risk that any users other than administrators can view the
source of the ASP file. |
1. | Start the UDL Wizard:
a. | Right-click your desktop and select New, and then Text Document. | b. | Rename the new text document as
My.udl. Press ENTER. | c. | You will receive a warning about renaming the file
extension. Click yes. Note that the file's icon now looks like a computer with a
datasheet in the background.
|
|
2. | Next, double-click My.udl and use the Wizard as follows:
a. | Click the Provider tab. | b. | From the Providers menu, select Microsoft Jet 4.0 OLE DB Provider, and then click Next to proceed to the Connections tab. |
|
3. | On the Connections tab:
a. | Type your database name or browse to the database you
want to connect to. | b. | If you have created an account to use for Internet
connections to the database, enter those credentials. Otherwise, you can use
the default settings (Admin, no password). (To use the default settings, enter
Admin as the user name, and then select the Blank Password checkbox). If you do not want to use the default credentials,
follow the steps under "Additional Information," later in this article, to
configure the System database. | c. | Click ok, which will close the Wizard. |
|
4. | Next, right-click My.udl file and rename it as My.txt. Click yes in the warning dialog box that appears. |
5. | Double-click My.txt, and a statement similar to the following will appear:
[oledb]
; Everything after this line is an OLE DB initstring
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\My.mdb;User ID=;Password=;
|
The following line is the connection string from My.txt:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\My.mdb;User ID=;Password=;
The following sample code illustrates how this
connection string can be incorporated into an ASP page:
Set objCXN = Server.CreateObject("ADODB.Connection")
strCXN = "Microsoft.Jet.OLEDB.4.0;Data Source=C:\My.mdb;User ID=;Password=;"
objCXN.Open strCXN
.
.
.
objCXN.Close
Set objCXN = Nothing
Note Do not use �objCXN.Open("DSN=...)�, because you are no longer
using a DSN connection.
Additional Information
If you are specifying an Access database username and password,
use the following steps to specify the path and the password to access the
SYSTEM.mdw file.
In the UDL Wizard:
1. | Click the All tab. |
2. | Select the field labeled Jet OLEDB.System database. |
3. | Click Edit Value. |
4. | In the Property Value box, type the path to the SYSTEM.mdw file:
Windows NT 4: C:\winnt\system32\System.mdw
Windows 2000: C:\Program Files\Common Files\System\System.mdw |
5. | Click OK in the Edit Property Value window. |
6. | Select the field labeled Jet OLEDB:Database Password. |
7. | Click Edit Value. |
8. | In the Property Value box, type the password for the System database. |
9. | Click OK in the Edit Property Value window. |
10. | Click OK to close the Data Link Properties window. |
The final Connection String should look like this:
Provider=Microsoft.Jet.OLEDB.4.0;Password=joe;User ID=jim;Data Source=C:\My.mdb;Persist Security Info=True;Jet OLEDB:System database=C:\Program Files\Common Files\System\SYSTEM.MDW;Jet OLEDB:Database Password=14323