.NET
  Home arrow .NET arrow Page 2 - Working with ADO.NET
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Working with ADO.NET
By: Anand Narayanaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 20
    2005-08-29

    Table of Contents:
  • Working with ADO.NET
  • Connecting to the database
  • Inserting Records
  • Searching Records

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Working with ADO.NET - Connecting to the database


    (Page 2 of 4 )

    In order to establish a connection to the database you have to follow a three step procedure as outlined below.

    The first step is to add the OleDbDataAdapter control to the form. Double click the control from the Data section of the Toolbox (see figure 3).

    The Data Adapter Configuration Wizard opens up (see figure 4).

    Click Next to continue and select the New Connection button as shown in the figure below.

    Select the Provider tab from the DataLink Properties dialog and click the Microsoft Jet 4.0 OLE DB Provider option (see figure 6).

    Click the Next button to continue and select your MS Access database, which will be used for this application. You can click the Test Connection button to verify the connection, which will show any errors which will possibly occur while establishing a connection to a database (see figure 7).

    Click the Next button on the adapter wizard until you see a dialog called Generate the SQL Statements. You can use the Query Builder to generate the required SQL Statement. Add the table name from the Add Table dialog and click the * mark on the builder. The system will generate a SQL statement similar to one shown below:

    SELECT  <Your Table Name>.*

    FROM    <Your Table Name>

    The above statement will be sufficient for our sample application. You can now click the Next button on the wizard and the whole process is over as soon as you click the Finish button. The wizard will display any errors which may occur during the generation of the SQL statement. I have not selected a column as primary key while creating the database. Hence the wizard will show a warning. This is not an error (see figure 8).

    The second step is to add the OleDBConnection control to the form. You need not perform any additional work for this control because this will be used for connecting to the database.

    The final step is to generate a dataset. Select the Generate DataSet menu option from the Data menu. The Generate DataSet dialog opens. Choose the option New, give a meaningful name, and close the dialog by clicking the OK button.

    You will notice that all three Data controls will appear on the bottom tray of the form, as they are not visible during run time. The above procedure is not yet complete, because you have to fill the data adapter with the dataset. This can be done using one line of code as shown below:

    OleDbDataAdapter1.Fill(DsCustomers1)

    You need not provide any further code because everything will be automatically done in the background by Visual Studio .NET 2003.

    More .NET Articles
    More By Anand Narayanaswamy


       · I am the author for the article - Working with ADO.NET. I hope you will find this...
       · Hi, how to use Dataset with ADO.Net ? there is any free material is there in...
       · Please checkhttp://msdn.microsoft.com/msdnmag/issues/02/01/data/A google...
       · The iGrep search will help you more than Google or any other search. The iGrep...
     

    .NET ARTICLES

    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT