Sunday 31 March 2013

DataSet in Ado.Net !!

Hello Friends !! Today i am just going to explain about DataSet in Ado.Net which is as given below
DataSet !!

  • DataSet is tabular representation of data. Tabular representation means it represents data into row and column format.
  • We use DataSet in disconnected Mode.
  • The DataSet object belongs to System.Data namespace. 
  • The Dataset can hold records of more than one Database tables or DataTable. 
  • Whenever we   use dataset into our application then Generally DataAdapter object is used with DataSet to fill DataSet with value. 
  • The SqlDataAdepter object allows us to populate DataTable in a DataSet.
  • We use Fill method of the DataAdapter for populating data in a Dataset. 


 Let's look a simple example to using DataSet. Below code shows how to create a new data set object and give it a name.

Syntax:

            DataSet ds = new DataSet ();

Source Code:

private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("data source=.;initial catalog=project2;integrated security=true");
SqlDataAdapter da;
da=new SqlDataAdapter("select* from newuser where emailid='"+email_id.Text+"'and userpassword='"+password.Text+"'",con);
//  DataTable dt=new DataTable();
DataSet ds = new DataSet();
da.Fill(ds);
if(ds.Tables[0].Rows.Count>0)
//if (dt.Rows.Count > 0)
{
NEWUSER nu = new NEWUSER();
nu.Show();

}
else
{
MessageBox.Show("invalid id ");
}

Source code Screen:

    
                                                                                                        <<Next-Topic>>
 I hope this post will help you ..
If you've some query regarding to this article then please post your comment.your comment will be appropriate . 


0 comments:

Post a Comment

Hey thanax alot to comment i will revert you back soon...

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites