What are the commonly used methods of Dataadapter in ADO.NET?

Dataadapter has several methods associated with it.



Most commonly used methods among them are listed below:

Fill: Fill method is used to fetch records from the database and update them into the datatables of dataset. Uses SelectCommand for execution. Syntax for Fill method is : sampleAdapter.Fill(employee,”Employee”);
Here sampleAdapter is a SqlDataAdapter containing select query for Employee, employee is the dataset and Employee is the database table.

FillSchema: FillSchema method is used to create an empty table in dataset containing the same schema as that of a specific table in the database. Constraints of the corresponding database table is also copied and reflected in the datatable of dataset. Uses SelectCommand for execution but copies only the schema of the table and not the data. Syntax for this method is shown below:
sampleAdapter.FillSchema(empDataSet, SchemaType.Source, "Employee");
Here empDataSet is the dataset and Employee is the database table name.

Update: Manipulated records of the dataset are updated back in the database using this method. Records that are inserted, updated and deleted from the dataset are pushed into the database using this method. Uses InsertCommand or UpdateCommand or DeleteCommand for the above mentioned purpose. Syntax for Update method is shown below:
sampleAdapter.Update(employeeTable);
Before this statement, sampleAdapter will include an UpdateCommand. employeeTable is the datatable of the dataset.

Dispose: This method is used to release all resources used by the dataadapter. Here is the syntax:
sampleAdapter.Dispose();

| How do you implement Observer Design Pattern in .NET? | How do you pass data between different Tiers in .NET Architecture? | How is Classic ADO different from ADO.NET? | How is Dataadapter useful in ADO.NET? | How is Datareader different from Dataset in ADO.NET? | How is .NET Application Development different from Traditional Development? | How is HashTable different from ArrayList in .NET? | How is Inheritance achieved in C#? | How is new keyword different from override keyword during inheritance in .NET? | How is String class different from StringBuilder class in .NET? | Illustrate ADO.NET Architecture | Illustrate the importance of Server.Transfer and Response.Redirect in .NET? | Mention the different objects available in Dataset of ADO.NET | Mention the usage of Connection Object in ADO.NET | What are the commonly used methods of Dataadapter in ADO.NET? | What are the different Behavioral Design Patterns that can be used in .NET Architecture? | What are the different Creational Design Patterns that can be used in .NET Architecture? | What are the different Structural Design Patterns that can be used in .NET Architecture? | What are the methods provided by Command Objects in ADO.NET? | What is Internal Access Modifier in C#? |


“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”

| Privacy Policy for www.dotnet-guide.com | Disclosure | Contact |

Copyright - © 2004 - 2024 - All Rights Reserved.