TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

ADO.Net Dataadapter

ADO Net Dataadapter with introduction, data providers, sql server connectivity, connection, command, datareader, dataset, dataadapter, datatables, web form examples, mvc examples etc.

<< Back to ADO

ADO.NET DataAdapter

The DataAdapter works as a bridge between a DataSet and a data source to retrieve data. DataAdapter is a class that represents a set of SQL commands and a database connection. It can be used to fill the DataSet and update the data source.

DataAdapter Class Signature

public class DataAdapter : System.ComponentModel.Component, System.Data.IDataAdapter

DataAdapter Constructors

Constructors Description
DataAdapter() It is used to initialize a new instance of a DataAdapter class.
DataAdapter(DataAdapter) It is used to initializes a new instance of a DataAdapter class from an existing object of the same type.

Methods

Method Description
CloneInternals() It is used to create a copy of this instance of DataAdapter.
Dispose(Boolean) It is used to release the unmanaged resources used by the DataAdapter.
Fill(DataSet) It is used to add rows in the DataSet to match those in the data source.
FillSchema(DataSet, SchemaType, String, IDataReader) It is used to add a DataTable to the specified DataSet.
GetFillParameters() It is used to get the parameters set by the user when executing an SQL SELECT statement.
ResetFillLoadOption() It is used to reset FillLoadOption to its default state.
ShouldSerializeAcceptChangesDuringFill() It determines whether the AcceptChangesDuringFill property should be persisted or not.
ShouldSerializeFillLoadOption() It determines whether the FillLoadOption property should be persisted or not.
ShouldSerializeTableMappings() It determines whether one or more DataTableMapping objects exist or not.
Update(DataSet) It is used to call the respective INSERT, UPDATE, or DELETE statements.

Example

// DataSetDemo.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DataSetDemo.aspx.cs" 
Inherits="DataSetExample.DataSetDemo" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>

        </div>
        <asp:GridView ID="GridView1" runat="server" CellPadding="3" BackColor="#DEBA84" 
		BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellSpacing="2">
            <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
            <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
            <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
            <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
            <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#FFF1D4" />
            <SortedAscendingHeaderStyle BackColor="#B95C30" />
            <SortedDescendingCellStyle BackColor="#F1E5CE" />
            <SortedDescendingHeaderStyle BackColor="#93451F" />
        </asp:GridView>
    </form>
</body>
</html>

CodeBehind

using System;
using System.Data.SqlClient;
using System.Data;
namespace DataSetExample
{
    public partial class DataSetDemo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            using (SqlConnection con = new SqlConnection("data source=.; database=student; integrated security=SSPI"))
            {
                SqlDataAdapter sde = new SqlDataAdapter("Select * from student", con);
                DataSet ds = new DataSet();
                sde.Fill(ds);
                GridView1.DataSource = ds;
                GridView1.DataBind();
            }
        }
    }
}

Output:

ADO Net Dataadapter 1
Next TopicADO.NET DataTables




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf