Paste the class code into notepad and save it as caDataGrid.asp in your wwwroot
folder. I use the nwind.mdb database as an example here which is found with plenty
of MS products, in my case in my Visual Basic folder. I copied the database to
the wwwroot folder for simplicity. Now create an asp page in your wwwroot folder
with the following:- <%@ LANGUAGE="VBSCRIPT" %>
<% option explicit %>
<% response.buffer=true %>
<html>
<head>
<title>caDataGrid Test</title>
</head>
<!-- #include file="caDataGrid.asp"-->
<body>
<%
dim cDataGrid, mapPath
Set cDataGrid = New caDataGrid
mapPath = "nwind.mdb"
'Access 2000 connection
cDataGrid.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&
Server.MapPath(mapPath)
cDataGrid.SqlString = "select firstname, lastname, title from employees"
cDataGrid.Bind
set cDataGrid = nothing
'now lets set our own columns
response.write "<br><br>"
Set cDataGrid = New caDataGrid
cDataGrid.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&
Server.MapPath(mapPath)
cDataGrid.SqlString = "select firstname, lastname, title from employees"
cDataGrid.AutoColumns = false
cDataGrid.AddColumn("First Name")
cDataGrid.AddColumn("Last Name")
cDataGrid.AddColumn("Job Title")
cDataGrid.Bind
set cDataGrid = nothing
%>
</body>
</html>
You 'reference' the class using the include capability of asp. Of course theres
nothing to say you can't just paste your class code into the same page but it
wouldn't be nice and neat would it? Then you declare a variable and set it as
a caDataGrid object/class, assign the relevent values and bind. All of
5/6 lines of code. Very handy.
If you have been paying attention you might have realised how much more you could
do with this. First on the list should be better error code. For example if I
set cDataGrid.AutoColumns = false and then forget to add column names then I'd
have get bad output. On the more interesting side of things I could add alot
of similar stuff to this class as you find with the .net datagrid - paging, background
colours or even class names from a stylesheet all with some more properties and
methods. More work obviously but once it's done it'll be there to use many many
times. Until tomorrow when you install the .net framework and forget all about
it. Anyway hope this is of use to you all. Happy Coding.
Creating a Datagrid Class in classic ASP
- Introduction
- 2-Dimensional Arrays
- Creating the class
- Analysis of the Class
- More Analysis of the Class
- Using the Class in an asp page
Using the Class in an asp page
You might also like...
About the author
Brian O'Connell
Microsoft Certified Applications Developer with 10 years experience developing web based applications using asp, asp.net for a Local Authority in Dublin. Clings to a firm belief that a web appli...
Interested in writing for us? Find out more.
VB 6 books
-
Dynamic Web Application Development with ASP.Net (Computing)
This is the latest book from Cengage Learning on "Dynamic Web Application Development with ASP.NET...
VB 6 forum discussion
-
CorelDRAW VBA: cdrTraceLineDrawing FAILS, producing single linear path instead of Centerline trace?
by dancemanj (0 replies)
-
client/server application using activex
by beautifulheart (0 replies)
-
System Error &H8007007E. The specifed module could not be found.
by swiftsafe (5 replies)
-
Invitation to take part in an academic research study
by researchlab (0 replies)
-
Invitation to take part in an academic research study
by researchlab (0 replies)
VB 6 podcasts
-
Hanselminutes: Startup Series: Buying an Existing Small Company or Online Application
Published 8 years ago, running time 0h34m
Scott talks to Rob Walling about how he purchases small niche products and companies online and revitalizes them. He recently purchased an existing product that consisted of a 300 gig database and tens of thousands of lines of Classic ASP. How did he know it was valuable? What's next?
Comments