ASP.Net Setup for SQL
It is assumed at this point that you have a SQL server installed and running. - You do? - Good! - Let's get started.
We need to create a database in SQL for ASP.Net and assign at least one user so ASP.Net can 'talk' to the SQL database. -
Note: This user IS NOT a user that will be logging in from a web page to gain access to the 'private' area(s)
on your website. - This user will be be the one ASP.Net uses to communicate to SQL with.
Okay - Here we go.
For this excersise, we'll create a database called 'asp_demo'. - This is a very easy step (trust me).
You'll need to access your SQL server. - If you've installed the 'Express' version, you'll probably use the 'add-on'
SQL Management Studio. - If you've installed SQL Server 2000 (as in our previous documentation), you'll use 'Enterprise SQL
Services Manager'. - We'll continue as with our setup (using MS SQL Server 2000).
Start 'Enterprise SQL Services Manager' by clicking on:
Start->All Programs->Microsoft SQL Server->Enterprise Manager. - Whatever it takes - log into your SQL server so you can create
& manage databases. - Hint: You might want to right-click on this file & drag it to your desktop to create as shortcut. -
You'll be using this often.

For this excercise, we'll be creating a database called 'asp_demo'.
After your SQL manager opens, expand out the items until you see 'Databases' and click on it. - You should see all the
databases you currently have.
Now right-click on 'Databases' and click on 'New Database'

This is pretty easy. - Enter the name of the databsse you want ('asp_demo') in the 'Name' block and click on
'OK'.

If you'll look below, we now have a 'jpnol' Database shown in the listing:

Now we need a 'user' for this new database so our ASP.Net Login can access it. - We'll create a user called:
'asp_demo_access' with a password of 'asp_password'. - Let's do this now.
Expand 'Security' and click on 'Logins'. You'll see what logins/users you have now. - Right click 'Logins' and
click on 'New User', the 'New User Login' box will appear.
In this box enter the login name in the 'Name' field ('asp_demo_access').
Click the 'SQL Server Authentication' method and enter the password for the login in the 'Password' box
('asp_password'). - Hint: You might want to write these down, you'll need them later.
Now click the 'down-arrow' next to the Database field and select 'asp_demo' as the default database.
Click 'OK' to continue.

You're now presented a password confirmation box, re-enter the password ('asp_password') and click
'OK'.

You're user has been set up and 'granted' access to the 'asp_demo' database. But user, 'asp_demo_access', still needs
to be configured so this user can use it (we'll do that next - I know - it sounds confusing). - Just click
'Yes'.

In Enterprise Manager, click on 'Security' then 'Logins'. You'll see all users that are defined.

Right click on 'asp_demo_access' and click on 'Properties'. - When this opens, click on the 'Database Access' tab. -
Here's where you tell SQL that user 'demo_access' can have access to the 'asp_demo' database.

In the top section, make sure 'asp_demo' is checked.
In the bottom section, just make sure that 'db_owner' is checked. - Later we can 'tweak' these permissions to
tighten it up for security reasons.
Click on 'OK'.

We're now finished with 'Enterprise Manager', you can close it so we can move on.
Configuring the SQL Database so the ASP.Net login control will work.
For the login control to work, your database has to be initialized with the tables ASP.Net will need. - We'll do
that with a program called 'aspnet_regsql.exe' found within the ASP's Net Framework.
Click on start and select 'Run'. - Navigate/browse to:
C:\Windows\Microsoft.Net\Framework\V#########\aspnet_regsql.exe and click 'Open' to select this file. - Note: V######
is the version number of Net Framwork you have installed (mine is V2.0......).

Making sure you have selected 'aspnet_regsql.exe' in the 'Open' box, click 'OK' to start the program.

You should see the ASP.NET SQL Server Setup Wizard welcome screen. Click 'Next' to continue.

For Setup Option, make sure 'Configure SQL Server for application services' is selected. - Now click
'Next'.

In the next step, select 'asp_demo' as the 'Database' to modify and click 'Next'. - Don't worry about the
'Server' name, yours will be different from mine.

Here's your last cance to bail out. - On the confirmation screen, make sure that you have made the right selections. -
Again, don't worry about the 'Server' name. - Your's will be different than mine. - Click 'Next' to start
configuring.

Well - This process doesn't take very long. - When it's finished, you'll see this notice. - Click 'Finish'
to close the program.

For the curious. - What did we just do?
Basically, we added a few 'tables' to the 'asp_demo' database. - You see, in SQL, data is kept in the database in what
we call 'tables'. - Tables look sort of like Excel spreadsheets and our application will access these tables to read and
write data from and to.
If you want, go back into 'Enterprise Manager', expand 'Databases', 'asp_demo', and click on 'Tables'. - You'll see
the tables within 'asp_demo' on your right.
Tables I've outlined in red are the default tables when the database was created.
Tables I've outlined in green are tables we just set up when we ran
'aspnet_regsql.exe program.
Of the eleven tables we created with 'aspnet_regsql.exe', only five are used with the 'Login Control'. - I've outlined
these in blue.

That's it. - You can close 'Enterprise Manager' and you should be 'good to go' for setting up your ASP.Net Login Control
(well.... as far as the SQL database is concerned anyway).
|