UltraDevGuru.com
 
UltraDevGuru.com - Tutorials
 

 

Creating a Server side DSN-less connection string.

 

This seems to cause an awful lot of problems for lots of users, hopefully this tutorial will make that a thing of the past. Also, a lot of web hosting companies give you the connection string to use, and it often includes 'Server.MapPath' which cannot currently be entered into the UltraDev connections dialog box. But there is a little trick you can use to get the absolute path to your database.

1. Create a web page containing the following ASP code:

<%LANGUAGE="VBSCRIPT"%>
<%=Server.MapPath("user_name/database/database_name.mdb;")%>

(Or cut and paste this text file into and editor and save as test.asp it is packaged in a .zip file)

2. Now upload this page to your web server/host, and view the page in your browser. You should now see the value stored in the Server.MapPath variable.

3. Now to create your DSN-less connection string, you also need the information your web host gave you for your site.

For example IMG2.com, your other details would be /user_name/database/db_name.mdb

where user_name is your username, database is the directory where your database MUST be placed (due to permission settings) and db_name.mdb is whatever you called your access database.

3. If you take the value of Server.MapPath that was output from the web page we created above, and append your info to the end, we have half of the connection string.

4. Now we need the first half, which basically tells the web server what database driver file to use. For an Access database, the options will probably be:

Provider=MSDASQL;Driver={Microsoft Access Driver (*.mdb)};DBQ= (Here you put the information you have just found in the previous steps)

or

Provider=Microsoft.Ace.OLEDB.12.0;Data Source= (Here you put the information you have just found in the previous steps) ;

So, your connection string for IMG2.com would be something like:

Provider=Microsoft.Ace.OLEDB.12.0;Data Source=e:/Inetpub/users/USER_NAME/database/DATABASE_NAME.mdb;

 

5. Now you need to decide which type of design environment you are working in:

 

 
   
Copyright 2000 Bill Kennelly - BKWeb. All Rights Reserved.
All products and trademarks mentioned in this site are acknowledged and are trademarks of their respective owners.