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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kunal NaikPosted May 12, 2012, 1:20 AM
Refer following links,
Link1
Link2
Kunal VaishyaPosted May 12, 2012, 12:47 AM
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
Satyapriya NayakPosted May 12, 2012, 12:35 AM
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