Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 96,641 times

Contents

Related Categories

Creating a Members Area in ASP - Preparation

Preparation

For this example, we are going to use a MS SQL Server database. This doesn't mean you have to, as the SQL statements will work whatever the database; you'll just need to change the connection code.

Before we start writing any ASP code, create a new MS SQL Server database called testdb, and then create a new table in it called members. Add the following columns (we've included both the MS SQL Server, and the Access descriptions)

Name SQL Server Data Type

Access Data Type

Notes
id int (AutoIncrement=True) AutoNumber Primary Key
username varchar (20) Text (FieldSize=20) Unique
password varchar (20) Text (FieldSize=20)  

Now, we'll create a short ASP script that connects to the database. Save it as inc-dbconnection.asp.

inc-dbconnection.asp

<%
Dim objConn

'create an ADO connection object
Set objConn = Server.CreateObject("ADODB.Connection")

'open the connection to the database
'sqlservername = the name of the SQL server (if used)
'accessdb = the path to the access db from this script
'username = username to connect to the db
'password = password to connect to the db

'// Use this for SQL Server
objConn.Open "Driver={SQL Server};Server=sqlservername;" & _
    "UID=username;PASSWORD=password;DATABASE=testdb;"

'// Use this for an Access 2000 database
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("accessdb")

'// Use this for an Access database (earlier than 2000)
objConn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & Server.MapPath("accessdb")

'we are now connected to the database
%>

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments

  • Re: [1744] Creating a Members Area in ASP

    Posted by root on 13 Aug 2008

    Hello, thanks for the code it really works!

    Actually I´m using SQL Server 2000 and it is possible to register the users with the same user name, and there is not any me...

  • Re: [1744] Creating a Members Area in ASP

    Posted by shawne on 11 May 2007

    I want to with u a happy day .. And thank's once again for giving us the source code.. but unfortunately i just use your code for my following project but then i got some error said ---The include ...

  • Re: [1744] Creating a Members Area in ASP

    Posted by rob1210 on 15 Feb 2007

    Hi, being a bit of a newbee to ASP but am quite up to speed with SQL and some web development. I am struggling a little with getting to grips with what I need to do with some of the code. In the tutor...

  • Re: registration form

    Posted by nathancan on 20 Nov 2006

    If I look at the page in Dreamweaver or similar I also see the code.  However, when it is uploaded to my web server it appears without the code.
    Are you sure your web server can run asp?

  • Re: [1744] Creating a Members Area in ASP

    Posted by nathancan on 20 Nov 2006

    Hi there
    I'm new to asp and thought i'd start applyinh what I've been reading by using this tutorial. When I attempt to use login.asp or register.asp I receive the following error: