SunQuest
 
       ASP
  Home arrow ASP arrow Page 2 - ADO.NET 101: Data Rendering with a DataGri...
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 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
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? 
ASP

ADO.NET 101: Data Rendering with a DataGrid Control
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 73
    2005-11-22

    Table of Contents:
  • ADO.NET 101: Data Rendering with a DataGrid Control
  • Displaying Data from DataReader with a DataGrid Control
  • Connecting to a SQL Server database
  • Adding a SQL Connection
  • Adding a SQLCommand
  • Display formatted data using AutoFormat
  • Formatting via Code

  • 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
     
    Iron Speed
     
    ADVERTISEMENT

    Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!

    ADO.NET 101: Data Rendering with a DataGrid Control - Displaying Data from DataReader with a DataGrid Control


    (Page 2 of 7 )

    The first step is to start a new web application and change the default file name of the web form to something meaningful such as DataGridExample.aspx. Following this you need to make connections to a database by inserting the control SQLConnection; then, add a command to retrieve data using the control SQLCommand. This is followed by writing appropriate code to retrieve data using the DataReader as a source of the data. To display data you add DataGrid and then call the methods of the DataGrid to port the data to the DataGrid by calling the DataBind() method after indicating that the DataGrid's DataSource is the DataReader.

    Connecting to the SQL Server

    VS 2003 IDE has a menu item, Server Explorer, that lists all the connections made to the various servers, including SQL 2000 Server, MSDE, MS Access, and so on. If the sources are not moved they can be refreshed by going to the connection, right clicking the node and choosing Refresh. For example, the next picture shows refreshing a connection to the MS Access Database file.

    Refreshing connection to MS Access

    As to the SQL 2000 server, whether or not you have the correct version of the VS 2003 IDE, you will not be able to connect to a SQL Server. With a standard edition of VS 2003, you may connect only to MSDE and MS Access database servers.

    Warning connecting to SQL Server

    More ASP Articles
    More By Jayaram Krishnaswamy


       · "When the controls are bound to a data source, the three controls Repeater,...
       · I was away on a holiday where I did not have access to a computer(unbelievable, but...
     

    ASP ARTICLES

    - ADO for the Beginner
    - ADO.NET 101: Data Rendering with a DataGrid ...
    - Introducing SoftArtisans OfficeWriter 3.0 En...
    - Getting Remote Files With ASP
    - The Real Basics of Functions in ASP
    - Enhancing Readability with ASP
    - Mimicking PHP's String Formatting Functions
    - Windows Server Hacks 12, 77, and 98
    - How to Sort a Multi-Dimensional Array
    - Developing an Information Management Tool wi...
    - What are Active Server Pages?
    - Getting Remote Pages with ASP
    - FTP’ing Files with ASP
    - Apply Single-Sign-On to Your Application
    - Easy Error Management





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