Before you actually start to 'write' your application, you must create a database to put information into or take it from. On this step, you'll know how to create MSSQL database and populate it with data.
Here you have several variants:
Below we will describe the second variant.
For authorization and roles management we will use .Net Membership and Roles
(details). And to not create the related tables manually,
we will use the build-in .NET Server Registration Tool.
So, all that was left to do is to run ASP.NET SQL Server Registration Tool (Aspnet_regsql.exe, details). The tool comes with the .NET framework and generally can be found under: C:\WINDOWS\Microsoft.NET\Framework \%version%\aspnet_regsql.exe (the exact location you can know here).
Your action: Open command window and run the tool with the following keys:
aspnet_regsql.exe -E -S <servername> -d <databasename> -A mr
If you ran the tool successfully it will create 6 tables and database TaskManager (if it doesn’t exist yet):
All these tables are used by ASP.NET Membership for providing its functionality. Leave them as they are and move to creating tables that will store information concerning tasks and their statuses, i.e. create manually 2 tables:
Your action: in the database TaskManager, create 2 tables with the columns shown in the images below:
So, in the end you must have 8 tables:
To access the server database you should make the appropriate settings in the Web.config file. In the file you should rewrite the following configuration elements:
<connectionStrings> <add name="TaskManagerConnectionString" connectionString="Server=SQLEXPRESS\DHTMLX;Database=TaskManager;Integrated Security=SSPI;User Instance=true" providerName="System.Data.SqlClient" /> </connectionStrings>
<authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" timeout="2880" /> </authentication>
<membership defaultProvider="CustomMembershipProvider"> <providers> <clear/> <add name="CustomMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="TaskManagerConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> </providers> </membership>
<profile> <providers> <clear/> <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="TaskManagerConnectionString" applicationName="/" /> </providers> </profile>
<roleManager enabled="true"> <providers> <clear/> <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="TaskManagerConnectionString" applicationName="/" /> <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /> </providers> </roleManager>
The remaining configuration elements leave as they are.
We have already provided the connection settings. Now we are left to add the related connection, so you can use the database in your project.