Database Login Part 1 (Software and setting up)   Leave a comment

Within this 3 part tutorial I am going to show you how to program a user login complete with database, admin user interface and a privilege system.

Many people program very simple login systems along the lines of an if statement or two, this is good if you have one or two users but what if you have 15 users using an application and your always adding more; relaying on an if statement is just out of the question because when you add a new user you would have to recompile the application and deploy it every time. This is why we use a database to store our username’s and password’s because to add a new user all you have to do is add the user into the database and your done.

1) Software

For this tutorial we are going to use

Visual Basic 2008 (.net 3.5 however .net 4.0 MAY work, have not tested)

SQL server 2008 R2 Express edition.

New Database windowCreating a new database

2) The database

For this whole tutorial we are going to be using Microsoft SQL studio and database engine, if you have not done so allready and installed please see this post on how to install SQL studio.

First of start by connecting to your SQL server, in my case my “server name” is “JACK-PC\SQLSERVER” (without quotes). Expand the “databases” section under object explorer, right click on the “databases” tree you just expanded and select “New Database”. Enter a database name, for this instance we are going to call it “Login” (without quotes).

Now under “Databases” you should have your new Login database. Click on it and expand it, there should be a “Tables” sub tree. Right click the “Tables” sub tree and click “New table”. You should have a window similar to fig 2 and fill out according to fig 2

Table Config imageFig 2

1) Set the ID colum to primary key (number 2) and (is identity) = yes (Number 3)

2) Create all the other colums and set them to: Username = varchar(50), Password = varchar(50), Privilege = int.

3) Give the table the name “Users” (number 4) and save: File > save all.

There we go, you have created the database, please see part 2 for “logging in”.

Posted July 16, 2010 by ngththien in Uncategorized

Tagged with , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: