Requirements
Visual Studio 2015 Update 3
ASP.NET 4.5.2
SQL Server
If you want to connect to the SQL database into ASP.NET, using C#, it should follow the steps given below.
Step 1
Now, Open Visual Studio 2015 Update 3, go to the File >> New >> Project or use the shortcut key "Ctrl+Shift +N".
Step 2
Here, select Visual C# >> Web >> ASP.NET Web Application. Finally, click "OK" button.
Step 3
Here, you can select the template for your ASP.NET Application. We are choosing "Empty" here. Now, click OK button.
Step 4
Now, open the project and look for the Solution Explorer. Then open the default .aspx. If you want a Webform, you can add the page (Web Form). Add+New item (Ctrl+Shift+A). Now, we can create a login page, using ASP.NET code. You need to follow the drag and drop method. Here, we already created the login page.
Step 5
Now, open the project. If you want a SQL Server database, you can add the page (SQL Server database). Add+New item (Ctrl+Shift+A).
Here, you can select Visual C# and choose SQL Server database. Afterwards, click "OK" button.
open the new Window and click YES button.
Now, add this to the database in our project.
Step 6
Now, we can go to the Server Explorer and add your database. You can click the Tables and afterwards, click Add New Table.
Now, open the new table and you can fill the data, which is like (studentname, password) and afterwards, you click the Update . Then click database in update and subsequently click update the database, the database is updated.
we can click on the right click and click Show Table Data.Now, the data is stored.
Step 7
Now, you can add SQL Data Source. Drag and drop method. Here, click Configure Data Source
you can select the ConnectionString and Click NEXT button, we can choose Specify columns from a table or view and afterwards, click Next button.
Now, click
Test Query.Here, add the data and click Finish button.
Step 8
Now, you can go to CS(C# code) page and you will write the C# code, you can see the Loginpage.aspx code.
Step 9
Here, you need to run any Browser and after a few minutes, you will get some output. Now, we can insert the data into your database.
Step 10
Now, we can added the GridView. Drag and drop method needs to be used. Then you can choose the data source, it is sqlDataSource.the database data is added to GridView.
Step 11
Here, you need to run any Browser and after a few minutes, you will get an output. Now, we can view the data.