Database Connection Strings

Database Connection StringsLearn how to connect to different kinds of databases in ASP.

Although our ASP database tutorials all use MS Access connectionstrings, there are many sorts of database software out there for usewith ASP. This tutorial will show you how to connect with them.

MS ACCESS
First, we'll take a look at the regular MS Access Connection String:

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0; DBQ=" _
& Server.Mappath("db/users1.mdb") & "User ID=Administrator;Password=rev01t;"
Conn.Open

Some people have trouble with this string, so I decided to add another connection string in its place:

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.connectionstring = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" _
& Server.Mappath("db/users1.mdb") & ";User Id=Administrator;Password=rev01t;"
Conn.Open

One of these two should work out for you, where the Password isthe database password, or a combination of the User ID and the Passwordare given to restrict access to a certain table. Note: if you have no username or password, erase everything after the third to last ';' like so: & Server.Mappath("db/users1.mdb") & ";"
MS SQL
This is a less common alternative to Access databases,most commonly used by large scale websites. Here's our connectionstringto SQL:

set Conn = server.createobject("ADODB.Connection")
Conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=servername;User ID=username;_
Password=password;DATABASE=databasename;"

There's your MS SQL string. Be sure to change servername to thename of the server (localhost, computername, or IP), and to changeusername, password, and databasename to match those of your database.

Related Articles

  • Reading a Database
    Displaying data from a database is one of the most common uses of ASP.
    Heres some sample code:...
  • Alternating Row Colors
    Learn how to alternate row colors from database output using ASP.
  • Inserting Rows into a Database
    This tutorial will show you how to insert a row of data into a database using ASP and an MS Access database. You can do it on one ASP file, but well have two files: one processor page (proc.asp), and one form page (form.asp). Then, well make the MS Access database that corresponds to the ASP.
  • Alternating Rows: Mysql
    The first thing we need to do is connect to the database. I always put my db connection in a universal file, that way I can just change the variables once if I need to; but for the sake of the tutorial, im putting it in this file.
  • ASP.NET in Dreamweaver 8
    In this article you will be able to use the new features of dreamweaver 8 to connect to a SQL database and return the results to a datagrid.
  • Affiliate System
    A full affiliate system for you to add your affiliates!
  • Beginner JS Pt. 2
    This tutorial is a well laid out recipe for basic Javascript. The article is brief and is limited to three topics: Calling the Script, Writing Comments, and Doing Stuff (Basic). Illustrations make it easy.
  • PHP Navigation and Connecting to a MySQL Database
    PHP Navigation and Connecting to a MySQL Database
  • Make an RSS Feed Using PHP
    Learn the best way to turn your database information into an RSS feed.
  • Hit Counter
    Hit counters are used to track the amount of visitors there have been to a cetain page. I have looked through the internet and I have come up with 2 different ways to produce a hit counter.

Contact Web Design Outsource and get started today

Need Website Designing, Development, Redesigning, Maintenance and SEO services or help growing your company's web presence? Request a free Quote Now.

© 2011 WebDesign Solutions Inc.
Privacy Policy | Terms and Conditions | Sitemap | Links