ASP.NET Steps to connect db

First design the web page using web server controls, for example form, button, labels. Then connect your buttons to subroutines, using onclick="name of subroutine". After that Import the libraries, for example <%@ Import Namespace=”System.Data” %>

At the end make a script block and put your sub routines inside, like this
<script runat="server">

sub AddProd(Sender as object, e as EventArgs)

'All programming goes here

end sub


Add following 5 steps to above mentioned sub routine
5 step to make any programming logic in a sub routines
'Step1: Make a connection to databse, declare an object of SQLConnection Class and pass it's argument
'Step2: Pass a query to database, declare an object of SQLCommand Class and pass it's argument
'Step3: Open the connection
'Step4: Run your query
'Step5: Close your connection