Home arrow ASP arrow Page 3 - Real-Time Data Grid Part 1/2

Real-Time Data Grid Part 1/2

In part one of this two-part article Annette, show us how to create an ASP class that allows us to work with our databases through a web browser. It will allow us to update and delete records dynamically using JavaScript and XMLHTTP, without ever having to refresh the page.

Author Info:
By: Annette Tennison
Rating: 4 stars4 stars4 stars4 stars4 stars / 16
February 07, 2002
  1. · Real-Time Data Grid Part 1/2
  2. · Project Overview
  3. · The GetConnection function
  4. · The InitializeGrid routine
  5. · Conclusion

print this article

Real-Time Data Grid Part 1/2 - The GetConnection function
(Page 3 of 5 )

As mentioned on the previous page, the only job of the GetConnection function is to instantiate a new ADO connection object, connect to our SQL Server 2000 database, and if no errors occur, return that ADO connection object. Let's step through the contents of the GetConnection function:

Set objConn = Server.CreateObject("ADODB.Connection")

objConn.Open strConnectionString

It starts by instantiating the ADO connection object into a local variable named objConn. The open method of the ADO connection is called, passing in a variable named strConnectionString. If you look at the top of the dynamic.datagrid.asp class, then you'll see that the strConnectionString variable is defined there. We have defined strConnectionString at the top of dynamic.datagrid.asp so that it is global in a sense. It looks like this (you should change it to match the details of your database server):

strConnectionString = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=pubs; User Id=sa; Password="

In the connection string for our DynamicGrid class, I've set the database name to pubs. You scan change the database name to any database on your server, however I've used pubs because it is a common database available on every SQL server.

Set GetConnection = objConn

If Err.Number = 0 And objConn.Errors.Count = 0 Then

Exit Function


Err.Raise vbObjectError + 1001, "DynamicGrid", "Failed to create ADO Connection object"

End If

Next, we assign our ADO connection object to be returned by the GetConnection function. If any errors occurred either globally, or as part of the connection, then we raise an error using the VBScript Err.Raise method, which would cause our DynamicGrid class to spit an error directly to the browser.
blog comments powered by Disqus

- Central Scoreboard with Flash and ASP
- Calorie Counter Using WAP and ASP
- Creating PGP-Encrypted E-Mails Using ASP
- Be My Guest in ASP
- Session Replacement in ASP
- Securing ASP Data Access Credentials Using t...
- The Not So Ordinary Address Book
- Adding and Displaying Data Easily via ASP an...
- Sending Email From a Form in ASP
- Adding Member Services in ASP
- Removing Unconfirmed Members
- Trapping HTTP 500.100 - Internal Server Error
- So Many Rows, So Little Time! - Case Study
- XDO: An XML Engine Class for Classic ASP
- Credit Card Fraud Prevention Using ASP and C...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials