Windows Application Connectivity with SQL-Server using DataAdapter in ASP.Net C#

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.

Connection between Windows Application and SQL-Server using Wizard (TableAdapter Method)

Connection between Windows Application and SQL-Server using DataAdapter and SQLConnection Method

Click Here For – Create New DataBase and New Table in SQL-Server

below screen show the output of ms sql server sql server database connection in asp.net.

Connectivity Between Windows Application SQL-Server using DataAdater and SQLConnection

Connectivity Between Windows Application SQL-Server using DataAdater and SQLConnection

First Import this NameSpace for SQLConnectivity in ASP.Net

using System.Data.SqlClient;

Write below code on INSERT Button  in ASP.Net

private void btninsert_Click(object sender, EventArgs e)
{
string  strconn = “Data Source=.\\NEWSQLEXPRESS;Initial Catalog=’DEMO’;Integrated Security=True”;

SqlConnection SqlConn = new SqlConnection(strconn);
SqlDataAdapter SqlAdapter = new SqlDataAdapter(“insert into UserMst values (‘” + txtname.Text +”‘,’”+  txtcity.Text +”‘)”, SqlConn);
DataTable DT = new DataTable();
SqlAdapter.Fill(DT);

//Select Data from Database for Bind Gridview
SqlDataAdapter SqlSelectAdapter =new SqlDataAdapter(“Select * from UserMst”, SqlConn);
SqlSelectAdapter.Fill(DT);
GvData.DataSource = DT;
}

I hope you will enjoy this sql server database connection in asp.net, database connection in vb.net with sql server.

Leave a Reply

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

3 + 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="">