Developers Tutorials in ASP, PHP, ASP.NET, JSP, Python AND Ruby
 
Classic ASP ASP.NET PHP/mySQL JSP/Servlet Ajax Ruby Python Cold Fusion Perl
  Home |   Topics |   Search |   Login / Register |   Rss Feeds


Topics
» Classic ASP
» ASP.NET
» PHP/mySQL
» JSP/Servlet
» Ajax
» Ruby
» Python
» Cold Fusion
» Perl
Search news
Search for:

My Account
Email:

Password:


Register
Forgot password?

Listed in ASPin.com




site statistics



The very first step in accessing database information is to establish a connection with the database source. ADO provides the Connection object to manage connections between a Web page and a database.

To establish a connection, first create an instance of the Connection object.



The WebWeekly I sent out on June 23, 1999 discussed just how one should connect to a database to acheive maximum performance. In that article I said that folks should use a System DSN over a DSN-less connection. I feel like our President, because I now must admit that I was wrong. However, let me assure you my incorrect statements were not my fault (now I really sound like a politician!). Before I delve into my miscarriage of communication, let's take a step back and see how this whole thing started.


Now everybody can connect to a database. Simple database access is a huge feature of ASP and one of the most widely used by developers but when you are first learning, it's hard to separate the database stuff from the rest of the code so I made this example.

The output of this example is written below. The html is poor at best...

16 records found!



The following are a collection of OLE DB Connection Strings encapsulated as complete ASP files. These are a quick and easy way of getting data out of a range of database types.

The connection strings are highlighted in blue and the parts of the script you should change to suit your database location, name, table and field are in bold.



This tutorial shows you how to set up a LOCAL Data Source Name, or DSN. This means that if you set up a connection on your own home machine then you will be able to connect to the database though if you move your code and database onto a live internet websever you normally will need the dsn set up by your hosting company's server.

If you cannot get in touch with your hosting company you may want to connect to your database with a DSN-less connection.



The question is how can an ASP file connect to a particular Microsoft Access database and retrieve the necessary records or edit or delete those records. Well the answer to our problem is Microsoft's ADO (ActiveX Data Objects) technology. ADO offers us two objects namely the Connection and the Recordset object that will allow us to do this.

To make a connection to our database we must first create an instance (create our own copy of the object) of the connection object and create a variable that will hold the object.



For our examples on this site we have chosen to use OLEBD rather than ODBC connection strings as they are faster and more stable.

Below are 4 connection strings that you could use 2 OLEBD and 2 ODBC. One example for each provides the physical path of the database and the other uses the Server.MapPath function. We also use the ADO connection in our examples below to open the connection object and make an active connection.



I had to test Microsoft's Personal Webserver (PWS) in win 98 to access Remote SQL server 7.0 installed in a NT server. The clients to win 98 had LAN connections. Easy one , don't vote, have fun with PWS. In fact I tested my connection with this script, before I created an out of process server demo with VB.


To allow easy use of the ADO Data Objects to connect to an access database.
 
Can't Copy and Paste this?


Active Server Pages (ASP) is a server-side scripting language widely used to build dynamic Web pages. The ASP Engine processes the script on the Web server at the back end and sends only HTML to any browser. Since the script is processed at the server, the requesting browser will be catered, even if it does not support a scripting language.


This issue discuss connection pooling with ASP, ISAPI, IDC, and Visual Basic applications. Included is a discussion of ODBC 3.0 and the newest bug fix for ODBC. We first addressed this connection pooling in the Dec 10, 1996 issue of 15 Seconds, way before IIS 3.0 and the complication of Active Server pages.


 The results described in this document are independent findings. They reflect my opinions only and have no bearing on any other party. The data presented here and its interpretation does not relate in any way to Microsoft(TM) or to any other software developed by Microsoft.

All trademark names appearing in this document are used for editorial purposes only and to the benefit of the trademark owner, with no intention of infringing on that trademark.



ASP programmers for large firms are most often asked to connect UNIX systems to the Web. I was recently asked to convert an application that ran on a UNIX server and make it available on the Web. The trick was that the actual process was to still run on the UNIX server, and only the client side would be Web based. The UNIX server, once it was told what to do, would still run the financial calculating processes and then send an email to the client. This article discusses how to create a simple DLL in Visual Basic (VB) that will call a freeware Windows EXE that connects and sends commands using REXEC to a UNIX server using remote shell calls. With this tool you'll be able to control any UNIX server running any process from a Web page.


This step-by-step procedure demonstrates how to hand code an ActiveX Data Objects (ADO) data connection in an Active Server Pages (ASP) page.

For the purposes of this article, the sample to follow uses the Northwind sample database and establishes an ADO connection to both Microsoft Access and Microsoft SQL Server 7.0 or 2000.



 Databases are a invaluable tool for storing large amounts of data in a structured and organized way. If you had an online store you could use a database to hold all your products details, such as price and availability. Your webpage would need to access the information in the database to display the product and all its details.

Another example of information a database could store would be all the usernames and passwords for a particular website. Once someone tried to log in their username and password would be checked against the database, if the username and password were valid (i.e. already existed in the database) then they would be granted access to the protected pages of the site i.e. a members area.







What's New
Connecting to a database
System DSN or DSN-less Connection?
Connecting to a Database and Retrieving Results in 9 Easy Steps
ADO OLE DB Connection Strings
How to create a local DSN (Data Source Name)
How to connect to a database using AD0
Connecting to an Access database using a Connection String
Connect/Read Remote SQL
Easy Access ADO
ASP-Oracle Connectivity Using OO4O

Most Popular
Cross-Page Posting Example
Making a phpBB-style Editor - Part 2: The Processing
Populating a Drop Down Menu with Info. from a Database
Retrieving Column Names with values
Displaying last modified date of any file
Generating random passwords
AppendToLog in response object
Importing csv data into MySQL with php script
Image downloading from remote servers in ASP
Easy Access ADO

Copyright © 2008 Powered by GNews Publisher Positive. All rights reserved. Contact Us - Load Time: 0.20 second(s)