latest Post

What are the methods of DataSet?

It is used in disconnected architecture. It represent records in the form of Database table (Row and Column) format. It stores record of one or more tables.
Example:
  1. SqlDataAdapter da;  
  2. DataSet ds;  
  3. string strconn = "Data Source=YourServerName;Initial Catalog=EMP;Integrated Security=True";  
  4. private void Form1_Load(object sender, EventArgs e)  
  5. {  
  6.     da = new SqlDataAdapter("select * from userdet", strconn);  
  7.     ds = new System.Data.DataSet();  
  8.     da.Fill(ds);  
  9.     dataGridView1.DataSource = ds.Tables[0];  
  10. }  
Methods of DataSet: 
  • AcceptChanges(): This method saves changes which are made with records in a DataSet.
  • Clear(): This method clears (removes) all rows from DataSet.
  • Clone(): The clone method copy the structure of DataSet. Means it copy only schema not full records of DataSet.
  • Copy(): It copies the whole records with structure of DataSet.
  • RejectChanges(): This method discard changes which is made with DataSet and set the DataSet to previous stage (which was at first).
  • HasChanges(): This method return boolean value to show whether record of DataSet has changed or not. It returns true if any changes has made and false if no other changes made.
  • GetChanges(): This method keep copy of those record, which is changed or modified.

About Mallikarjun A

Mallikarjun A
Recommended Posts × +

0 comments:

Post a Comment