Summary
By completing this hands-on lab you have learned how to build your first web application with SQL Server 2012 and ASP.NET. More precisely, you have seen how to connect to a SQL Server database and implement the SELECT, INSERT, UPDATE and DELETE operations using ADO.NET. Additionally, you have seen how to store and read images in the database.
Here is a quick checklist you can use to get started building your first web application using SQL Server 2012 and ASP.NET:
- Install a SQL Server instance and select Windows Authentication. Select Mixed Authentication only if you need support for SQL Server authentication.
- During the installation process, provision at least one Windows user as a member of the SQL Server sysadmin server-level role using the Specify SQL Server Administrators option in setup. You will use this account after installation to grant access to SQL Server for your administrators, developers, users and applications.
- After SQL Server is installed, launch SQL Server Management Studio and log in with a server-level principal that has CREATE DATABASE privileges.
- Create your database.
- Change your database context to the newly created database. Do not forget to do this or you may make changes to the wrong database.
- Create the necessary database objects to support your application, including tables, views and stored procedures. Load initial data as required using Transact-SQL scripts, bulk insert, or the Import and Export Data tool.
- Create database roles to represent each type of user in your application.
- Grant the minimum privileges necessary to the database roles that your users and/or applications will need to access your database objects.
- Configure the connection string in your application to connect to your SQL Server instance. In the connection string, specify the instance you want the application to connect to, the authentication type to use (Windows Authentication or SQL Server Authentication) and credentials if necessary. Also be sure to specify the name of your database using the Initial Catalog attribute.
- Configure your ASP.NET application to connect to SQL Server using either the user’s security credentials or an application identity.