how to make a web app

this example accepts a pager number and service name from
an ASP page and places the info into an SQL database. 
There is also a C++ routine which will accept a bphonenumber
and a message, then fetch the pager number and service name 
from the database, and page the customer. if the service is 
sprint,mci,pagenet,or skytel,the page will occur over the
internet. otherwise the number is tone dialed.
 
step 1: add pager info to the database

1. start up Enterprise Manager
2. choose your database and select Tables
3. create a new Table, name "Pager"
4. the three fields i want to add are
   PagerService
   PagerPIN
   PagerNumber
5. but i need to start with CustomerID
   (all our tables are indexed by CustomerID)
6. add to Table
   CustomerID     uniqueidentifier   16
   PagerService   varchar            20
   PagerPIN       varchar            10
   PagerNumber    char               10
note: varchar has a variable # of characters. char is fixed.

step 2: create the data access stored procedure

1. start up Enterprise Manager
2. choose your database and select Stored Procedures
3. create a New Stored Procedure
4. add this to New Stored Procedure

   CREATE Procedure GetPager @BPhoneNumber char(10),
                             @PagerService varchar(20) out,
                             @PagerPIN varchar(10) out,
                             @PagerNumber char(10) out
   AS BEGIN
     DECLARE @CustomerID uniqueidentifier
     SELECT @CustomerID = CustomerID
       FROM Customer
     WHERE BPhoneNumber = @BPhoneNumber
     SELECT @PagerService = PagerService,
            @PagerPIN = PagerPIN,
            @PagerNumber = PagerNumber 
       FROM Pager
     WHERE CustomerID = @CustomerID
     IF @@rowcount <> 0
        RETURN 0
     ELSE
        RETURN -1
     END

step 3: make sure you have a .DSN file that allows connection

1. Control Panel..ODBC Data Source Administrator
2. make sure you have the database.DSN file in File DSN
3. if not, locate it and copy it into 
   D:\Program Files\Common Files\ODBC\Data Sources
3. edit the database.DSN file and make sure it is correct

step 4: create a dboGetPager.H file to allow access from C++

1. start up Microsoft Visual C++ 6.0
2. add a New Project to your Workspace
3. make it a MFC AppWizard (DLL), name it "db"
4. make it a Regular DLL using shared MFC DLL
5. select automation and finish
6. select your new project
7. Insert..New ATL Object, answer YES
8. select Data Access, Consumer, Next
9. Select Datasource...
10. select Microsoft OLE DB Provider for ODBC drivers, next
11. select Use Connection String
    FILEDSN=database.DSN
12. Test Connection
13. select your data access stored procedure GetPager
14. you should now have a file called dboGetPager.H
15. edit it, and change "IN|OUT" to just "OUT"
16. compile and build
17. you'll have files called db.lib and db.dll

step 5. create Pager.cpp

1. start up Microsoft Visual C++ 6.0
2. add a New Project to your Workspace
3. make Pager a Win32 Console Application
4. make it an application that supports MFC
5. make sure StdAfx.h includes (use the pointy brackets)
   #include iostream
   #include afxinet.h
   #include atldbcli.h
6. right click on project and go to Settings..
7. under General, Use MFC in a Shared DLL
8. under Link, add to Object/library modules:
   ws2_32.lib db.lib
9. make sure the settings..link..input has the
   additional library path to db.lib
10. make sure the settings..c/c++..preprocessor has the
    additional include directory for dboGetPager.H
12. add to c++
    #include "dboGetPager.H"
13. add to c++
	CdboGetPager getPager;

	for (int i=0;i<11;i++)
		getPager.m_BPhoneNumber[i] = BPhoneNumber[i];

	getPager.Open();

	if (getPager.m_PagerService+1 == "k")
		myService = skytelPager;

	myPin = getPager.m_PagerPIN;
	myNumber = getPager.m_PagerNumber;

	getPager.Close();


back

Hosted by www.Geocities.ws

1