Databse Connection between ASP.Net and SQL-Server using Wizard

Database Connectivity between ASP.Net and SQL-Server

There are many method to make connection between ASP.Net and SQL-Server.

1. Connection using TableAdapter and StoredProcedure thought Wizards.
2. Connection using SQLCommand  and SQLDataAdapter using StoredProcedure .
3. Connection using SQLDataAdapter and SQLConnection writing query in webpage.

STEP 1 – Open the SQL-Server and Create New Database for connectivity.
Now Create New Table “UserMst” in Database Example.

Database Connection between ASP.Net and SQL-SERVER

Database Connection between ASP.Net and SQL-SERVER

STEP 2 – Create Stored Procedure for Select Data.

Database Connection between ASP.Net and SQL-SERVER

Database Connection between ASP.Net and SQL-SERVER

Fiil up the Record in Created Table named UserMst

Database Connection between ASP.Net and SQL-SERVER

Database Connection between ASP.Net and SQL-SERVER

STEP 3 – Now close the SQL Server and Open the Visual Studio .Net

Right Click on the Project Name then add App_Code folder from Add New ASP.NET Folder.

Database Connection between ASP.Net and SQL-SERVER

Database Connection between ASP.Net and SQL-SERVER

STEP 4 – Add new Dataset from Add new Item in App_Code folder..

Database Connection between ASP.Net and SQL-SERVER

Database Connection between ASP.Net and SQL-SERVER

After that do as below screen….

Database Connection between ASP.Net and SQL-SERVER

Database Connection between ASP.Net and SQL-SERVER

write your database server name and select below your Database for Connection.

Database Connection between ASP.Net and SQL-SERVER

Database Connection between ASP.Net and SQL-SERVER

Now click next button and select option ” Use Existing Stored Procedure” in below screen.

Database Connection between ASP.Net and SQL-SERVER

Database Connection between ASP.Net and SQL-SERVER

Now, Select the Stored Procedure which we created…

Database Connection between ASP.Net and SQL-SERVER

Database Connection between ASP.Net and SQL-SERVER

Now uncheck “fill a Data Table option below screen, and Write Select instead of GetData..

Database Connection between ASP.Net and SQL-SERVER

Database Connection between ASP.Net and SQL-SERVER

Here, we have DataTable and TableAdapter…

Database Connection between ASP.Net and SQL-SERVER

Database Connection between ASP.Net and SQL-SERVER

STEP 5 – Now save the project and go to the Default.aspx page.

Database Connection between ASP.Net and SQL-SERVER

Database Connection between ASP.Net and SQL-SERVER

STEP 6 – Write the below code in Button Click Event….

Database Connection between ASP.Net and SQL-SERVER

Database Connection between ASP.Net and SQL-SERVER

 protected void btngetdata_Click(object sender, EventArgs e)
{
// Declare DataTable and TableAdapter Object here..
User_DS.USERMST_SELECTDataTable USerDT = new User_DS.USERMST_SELECTDataTable();
User_DSTableAdapters.USERMST_SELECTTableAdapter UserAdapter = new User_DSTableAdapters.USERMST_SELECTTableAdapter();

USerDT=UserAdapter.Select();

GridView1.DataSource = USerDT;
GridView1.DataBind();

}

Database Connection between ASP.Net and SQL-SERVER

Database Connection between ASP.Net and SQL-SERVER

Now we have done connectivity between ASP.Net and SQL – Server

Leave a Reply

Your email address will not be published. Required fields are marked *

7 + 2 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">