![]() ![]() The context represents the given serialized stream from source to destination. It contains two parameters where the info is the data to make them serialize or de-serialize an object. DataSet class which gives the serialization information and the context. DataSet(Serialization info, StreamingContext context) is the same as above it initialize the new instance of the System.DataSet(String data SetName) it represents the name and it initializes the new instance of the class with the name it contains the string parameter dataSetName which specifies the name of the.DataSet() it derives from the class and initializes the new instance of a class.retrieving DataTable from the DataSet using name of the tableĬonsole.WriteLine(row + ", " + row + ", " + row + ", " + row) ĭataSet in C# provides four constructors, are as follows: Then second table we added was SalaryDetails table which the index position was 1, now we fetching this second table by using the name, so we fetching the DataTable from DataSet using the name of the table name "SalaryDetails", retrieving the DataTable from dataset using the Index positionįoreach (DataRow row in )Ĭonsole.WriteLine(row + ", " + row + ", " + row) ![]() to create the object for DataSetīy using index position, we can fetch the DataTable from DataSet, here first we added the Employee table so the index position of this table is 0, let's see the following code below (10002, 1002, "Briddan",30000) Īs we discussed the DataSet with the collection of DataTables, then create object for DataSet and then add two data tables (Employee and Salary) into the DataSet. to add the Data rows into the SalaryDetails table Then create the DataTable SalaryDetails, DataTable SalaryDetails = new DataTable("SalaryDetails") ĭataColumn SalaryId = new DataColumn("SalaryID", typeof(Int32)) ĭataColumn empId = new DataColumn("EmployeeID", typeof(Int32)) ĭataColumn empName = new DataColumn("EmployeeName", typeof(string)) ĭataColumn SalaryPaid = new DataColumn("Salary", typeof(Int32)) to add the Data rows into the EmployeeDetails tableĮ(1001, "Andrew", "9000322579") Į(1002, "Briddan", "9081223457") įor the salary table we creating the DataTable with the name SalaryDetails with attributes SalaryID, EmployeeID, EmployeeName, and Salary add the columns to the salary tables and then create two data rows and add those data rows into Salary tables. Let’s see the following coding below,Ĭreating the DataTable EmployeeDetails DataTable EmployeeDetails = new DataTable("EmployeeDetails") ĭataColumn EmployeeID = new DataColumn("EmpID", typeof(Int32)) ĭataColumn EmployeeName = new DataColumn("EmpName", typeof(string)) Į(EmployeeName) ĭataColumn EmployeeMobile = new DataColumn("EmpMobile", typeof(string)) Į(EmployeeMobile) Let’s understand the working procedure of DataSet in C# with example, We creating two data tables Employee and Salary tables and then create data columns to add the columns into the tables and finally create data rows to add records into both the tables. In this way, we can obtain the data without interacting with any data source because of a disconnected environment. The DataSet is a disconnected architecture that does not require an active or open connection to the database. It signifies the subset of databases in memory management. The syntax of DataSet as shown below, public class DataSet :, IListSource, ISupportInitializeNotification, ISerializable, IXmlSerializableĭataSet is a collection of data tables that contains the relational data in table structure. Web development, programming languages, Software testing & others
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |