ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing

ExpertRating Home
ExpertRating Benefits
Recommend ExpertRating
Suggest More Tests
Privacy Policy
FAQ
Login
 
ASP Dot Net Tutorial - Index
ASP Dot Net Tutorial - Microsofts ASP.NET
ASP Dot Net Tutorial - Begining Web Forms
ASP Dot Net Tutorial - User Controls
ASP Dot Net Tutorial - ADO .NET
ASP Dot Net Tutorial - DataBinding to WebControls
ASP Dot Net Tutorial - DataList Controls
ASP Dot Net Tutorial - DataGrid Control
ASP Dot Net Tutorial - Advance Practical Examples on DataGrid
ASP Dot Net Tutorial - Working with DataSets
ASP Dot Net Tutorial - Working with XML
ASP Dot Net Tutorial - Forms Based Authentication
ASP Dot Net Tutorial - Windows Based Authentication
     

 
Online Personal Trainer Certification
Personal Trainer Certification (Spanish)
Six Sigma Certification
Find a Personal Trainer
Project Management Certification
Six Sigma Certification
Six Sigma Black Belt Certification
Master Black Belt Certification
Six Sigma Green Belt Certification
Life Coach Certification
Lean Management Certification
Lean Six Sigma Certification
First Aid Certification
CPR Certification
Yoga Certification
Aerobics Certification
Pilates Certification
Business Analyst Certification
SEO Certification
Online Business Writing Course & Certification
Makeup Artist Certification
Baby Sitting Course & Certification
Time Management Certification
Health Club Management Certification
Medical Coding Certification
Medical Billing Certification
Business Analysis Course
Master Trainer Certification
Total Quality Management Certification
Kaizen Certification
Creative Writing Certification
Event Management Certification
Test Search by Job Title
Administrative Assistant Certification
Virtual Assistant Certification
  All Online Courses
   

   
   
   
   
   
   

   
  Home > Courses, Tutorials & eBooks > ASP.NET Tutorial > Working with DataSets
 

ASP.NET Tutorial - Working with DataSets

                                                                                                                 Page 2 of 5
 

Adding DataTable to a DataSet

The contents of existing database can be added to the tables of a DataSet by using the DataAdapter. To add a database table to a DataSet, use the following steps:

  • Create a DataSet.
  • Create a database connection.
  • Create a DataAdapter with a SQL Select statement and the database connection.
  • Call the Fill method of the Da±aAdapter, passing the name of the DataSet and the name of the new DataTable.

The following example, illustrates how the Employees can be added from the table from the Northwind database to a DataSet.

 

 The output of above example is shown below:

In the above example when the Fill method is called , a new DataTable is added to the DataSet, named Employees. Therefore the connection to a database is never open. The Fill method by itself opens a database connection and then auto­matically closes the connection that it opens.

The page in above example works only with a Microsoft SQL Server (version 7.0 and higher) database. It uses the SqlConnection and SqlDataAdapter classes from the System. Data. SqlClient namespace. If another type of database, is to be used such as Microsoft Access or Oracle, the classes must be used from the System. Data. OleDbnamespace.

The following example illustrates how a DataTable can be added from a Microsoft Access database to a DataSet.

 

 The output of above example is shown below:

In this example the classes from the System.Data.OleDb namespace are used. Instances of the oleDbConnection and OleDbAdapter classes are created.

       

 

 
     
Home  |  About Us  |  Privacy Policy  |  Site Map  |  FAQs  |  Contact Us
 
© ExpertRating 2015. All Rights Reserved.