Here, In this asp.net tutorials we will learn to make connection between SQL-Server and Windows Application in ASP.Net.
We can use many server for connectivity, here we will learn sql server database connection in asp.net. ms sql server is most popular database server.There are many names of SQL-Server like mssql server, ms sql server, sql server client, database server, mssql server…..
We can do this connectivity with multiple methods.
Before, going to ahead we need to create DataBase in SQL-Server,
Here, some step to create new sql-server Database in SQL-Management Studio.
STEP 1 – Open SQL-Server Management Studion and Create a New Database..
After opening SQL Server Create New DataBase
Write your New Database Name which you want to create in SQL-Server….and Click OK Button to Create New DataBase.
Now Create New Table in Database..
Create Column in your Table and Save Table with UserMst name.
After Creating Database and Table in SQL-Server, open the Visual Studio and Create New Windows Application in ASP.Net.
Open Visual Studio —> File –> New —> Project
Here, Select the Windows Form Application and write your Project Name, We create project named DEMO Here.
After Creating project you have a one Windows Form…..
Now, Here we create connection using Wizard so, Create New Folder at Solution Explorer and Create New DataSet in that DS Folder.
Open the DataSet1 and create New TableAdapter by Right clicking on DataSet1.
Then give your server name for new connection, just select your Database like below screen…
Then Click Next button and Select Use Existing Stored Procedure option on below screen.
Select the Stored Procedure for Select and Insert which are already you created in sql server.
Now, Remove the Fill a DataTable option and Next….
After Finishing this connectivity wizard, open your windows form and design like below:
Here, we have two TextBox Control Named txtname,txtcity and one Insert Button and one GridView Control.
Write Below code on INSERT Button Click Event:
private void btninsert_Click(object sender, EventArgs e)
DS.DataSet1.USERMST_SELECTDataTable UDT = new DEMO.DS.DataSet1.USERMST_SELECTDataTable();
DS.DataSet1TableAdapters.USERMST_SELECTTableAdapter UAdapter = new DEMO.DS.DataSet1TableAdapters.USERMST_SELECTTableAdapter();
int inst = UAdapter.Insert(txtname.Text, txtcity.Text);
txtname.Text = “”;
txtcity.Text = “”;
UDT = UAdapter.SelectData();
GvData.DataSource = UDT;
I hope you will enjoy this asp.net tutorials of sql server database connection in asp.net, database connection in vb.net with sql server.