HOME  |    TRAINING  |   FREE TUTORIALS   |   JOBS
Find out more about our new RSS feed.
FREE Tutorial
BEGINNING E-COMMERCE PART 2 - STARTING THE WROXCOMMERCE PROJECT

CATEGORY
SEARCH OUR OTHER TUTORIALS

DESCRIPTION

As we start our project the first thing we're going to look at is creating the root object of our model - the Visit object - and adding some basic configuration code to the Visit class module we build. We'll then move on to deal with the Database object via the Database class module.


This free tutorial is a sample from the book Beginning E-Commerce: with Visual Basic, ASP, SQL Server 7.0 and MTS.


Try It Out - Starting the Project

1. Start Visual Basic 6.0 and choose ActiveX DLL from the list of available projects:

2. When the project appears, use the Project Explorer and Properties window to rename the project to WroxCommerce and the object itself (called Class1) to Visit:

Thanks to the wonder of VB, we're now in a position where we could run our project and create and use instances of the Visit ActiveX object inside ASP! Revisiting our earlier ActiveX discussion, Active Scripting is now able, at the behest of ASP, to look at the properties and methods on that object from the type library and determine how to make the calls. But, we're not going to start using the object inside ASP just yet. Rather, for the remainder of this chapter we're going to continue putting the framework of our model together.

Adding the Configure Method

As we stated earlier, when we build our ASP pages, we're going to create an instance of the Visit object in code at the top of the page and add code to delete it at the bottom. This means that an instance of the Visit object will only exist for as long as the page is running. When the object is created it needs to have some information about the environment it exists in (mainly so it can connect to the database) and we're going to supply this information via the Configure method. As we want to be able to reuse this Visit object in other sites, we're going to tell it some other useful information, like the site name and the mail domain.

Try It Out - Creating the Configure Method

3. First of all, double-click on the Visit class in Project Explorer and enter the following code into the code window:

Option Explicit

' these variables hold the things about the site, 
' like the name and mail domain. We'll ' use 
' these later on...
Private m_strSiteName as String
Private m_strMailDomain as String

' this variable holds the connection string 
' needed to connect to the database...
Private m_strDBString as String

' Configure - tells the Visit object a little about the site...
Public Sub Configure(ByVal strSiteName As String, _
ByVal strMailDomain As String, ByVal strDBString As String)

' copy the site name, etc...
m_strSiteName = strSiteName
m_strMailDomain = strMailDomain

' copy the database details...
m_strDBString = strDBString

End Sub

4. Next we want to create a Shutdown method. So, add this code to Visit:

' Shutdown - releases any resources we may have open...
Public Sub Shutdown()

' we've got nothing to clean up yet, so we'll leave it blank...

End Sub

5. Then using the two drop-down lists at the top of the code editor window, select Class and Terminate and add the following:

' Called when the object is deleted...
Private Sub Class_Terminate()

' Make a call to Shutdown just to be sure...
Shutdown

End Sub

Continued...


NEXT PAGE



5 RELATED COURSES AVAILABLE
I-NET+ MODULE 13 - E-COMMERCE
On completion of this module, readers will be able to understand e-commerce terms and concepts.....
HTML 4.0 INTRODUCTION
To create, format and publish a small website using HTML 4.0. You will learn to create web pages incorporating fo....
MACROMEDIA DREAMWEAVER MX INTRODUCTION
To give an introduction to the Internet tools and features of Macromedia Dreamweaver MX. Readers will create an a....
MICROSOFT INTERNET EXPLORER 6.0 INTERNET INTRODUCTION
This course provides readers with an introduction to the concept of the Internet and the opportunity to gain a br....
A+ MODULE 5 - THE INTERNET
At the end of this course you will be able to: describe the functions of an operating system, describe the featur....
 
0 RELATED JOBS AVAILABLE
CONTACT US
Sunday 7th September 2008  © COPYRIGHT 2008 - VISUALSOFT