Hi Friends,
I want know about the data adapter and how can we use data adapter in database connectivity?
thank you
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted May 11, 2012, 8:35 PM EDT
Data adapter is nothing but the bridge between data source and data set.Data set is nothing but inline storage object.With data set you can develop same database schema with primary keys,relationships,foreign keys.
Example to display data in gridview using SqlDataAdapter
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Gridview._Default" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Gridview
{
public partial class _Default : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
SqlDataAdapter sqlda;
DataSet ds;
string str;
protected void Page_Load(object sender, EventArgs e)
{
bindgrid();
}
private void bindgrid()
{
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "select * from employee";
com = new SqlCommand(str, con);
sqlda = new SqlDataAdapter(com);
ds = new DataSet();
sqlda.Fill(ds, "employee");
g1.DataMember = "employee";
g1.DataSource = ds;
g1.DataBind();
con.Close();
}
}
}
Also Please refer the below links
http://www.dotnetfunda.com/articles/article1146-data-adapter.aspx
Thanks
Kunal VaishyaRank #990 · 2K reputationPosted May 11, 2012, 8:47 PM EDT
There so many benefit of DataAdapter the Part Of ADO.Net
refer this link to more understanding
http://asp-net-example.blogspot.in/2008/10/dataadapter-example-how-to-use.html
Kunal Naik163 reputationPosted May 11, 2012, 9:20 PM EDT
Refer following links,
Link1
Link2