ASP.NET
  Home arrow ASP.NET arrow Page 2 - Creating a StudentDB Class for ASP.NET 2.0
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? 
ASP.NET

Creating a StudentDB Class for ASP.NET 2.0
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 15
    2007-09-05

    Table of Contents:
  • Creating a StudentDB Class for ASP.NET 2.0
  • Creating the Website and the App_Code Folder
  • Writing the Student class
  • Storing the Connection String in a Web.Config file
  • The StudentDB class

  • 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


    Creating a StudentDB Class for ASP.NET 2.0 - Creating the Website and the App_Code Folder


    (Page 2 of 5 )

    Create a new ASP.NET website on the local file system and select Visual C# as the language. I will call the website TheSchool but you can call it whatever you like. You can accomplish this task from the menu option File ---> New ---> Web Site. Now we need to create the first class, which is the Student class. There is no data access code that will be written in that class. The Student class simply represents a row in the Students database table; the data access code will be written in the StudentDB class which has methods that accept instances of the Student class as a parameter and use this object to write a row to the database table. The best way to explain this is by example, so let's get to the code so you can understand what I mean. Don't worry though; we are going to talk more about this technique.

    You can create a new C# Class Library Project for the Student class and reference it from your website, but there is an easier technique that you will prefer for small to medium websites. New in ASP.NET 2.0 is the "ASP.NET Folders" feature which provides special folders that are used in your website for special functionalities. For example the App_Code folder is used to store your C# utility classes, data access and business logic code files, like our C# Student.cs file that we are going to create. 

    The classes you add to this folder will be compiled into an assembly and referenced from your web site code so you can access it without adding a reference to it. You can also organize your files, inside the App_Code folder, into subfolders and write as many classes as your application needs. So let's add this special folder to our website. Right click on the web site entry at Solution Explorer, select Add ASP.NET Folder, and then click on App_Code as shown in the next screenshot:

    Note that the App_Code folder has been added to the website's directory. Now right click on the App_Code folder, click on Add New Item, and then select a Class. Name this class Student.cs as shown in the next screenshot:

    Let's write that class.

    More ASP.NET Articles
    More By Michael Youssef


       · i haven't developed any real projects before because i still learning C# and asp.net...
       · Hi, Of course, you can read the article. It's not that difficult if you have...
       · A very good explanation, I visited ASP.net for first time and i find the very first...
       · Thanks, the next 2 article will be interesting more than this one. You will...
       · Very good article and can't wait for the second and third parts. are you going to...
       · Very good article and can't wait for the second and third parts. are you going to...
       · You will like the following articles even more.About the SqlDataSource control, I...
       · Nice article Michael but I need the other articles to complete the class. when we...
       · You will be reading the articles in the next few weeks. Tell me what do you think...
       · If you have an idea about an article related to ASP.NET 2.0 Data Access, please send...
       · Don't get me wrong the article is interesting. However, since it is broken in...
     

    ASP.NET ARTICLES

    - Developing a Mini ASP.NET AJAX Server Centri...
    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




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