Monday, September 8, 2008

ASP/SQL Server Based Chat program

By cdidave

Simple ASP/SQL Server Chat application

Introduction
This chat program was created simply because I didn’t want to buy one that had everything I wanted. This application is certainly not a complete application but it does take care of most general chat functions. I even included a few things some other applications don’t have such as smileys, language filters and room invitations.

Background
Since I have a content management system that uses a domain_id identifier, I wanted to be able to offer the chat program to many of my clients without having to create a database for each one of them. So I added the domain_id identifier to allow many domains to use it without cross contamination. You will see that almost all functions will filter by this identifier.

The database is SQL Server. I tried to use an Access database but I had trouble getting Access to support multiple recordsets in a singe SQL call. Instead of describing the database in detail, I have included a script that will build the SQL database. The data_access.asp contains the username and password that is written into the SQL script. These can be changed as long as they are the same in both places. I use a separate config file when I integrate these. For the demo, I simply hard coded them.

Using the code
Install
The code simply needs to be copied to any ASP virtual directory. No global.asa is needed. A database script is provided and just simply needs to be ran on the SQL Server with create database privileges.

Configure
In the install folder include/data_access.asp, simply replace the settings with your server info and you are all set. In my applications, this is an application variable. You may handle it however you wish.

Run
default.htm is a sample of how you can integrate the chat into any page. Sessions are used to track user info and stuff like that but by changing the domain_id parameter, you can run as many simultaneous instances as you want.

Happy chatting!

More...

http://www.codeproject.com/KB/asp/CDIChatSubmit.aspx

ASP.Net Feeds