ASP.NET
  Home arrow ASP.NET arrow Page 6 - Database Independent Development using ASP...
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

Database Independent Development using ASP.NET 2.0
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 21
    2007-02-14

    Table of Contents:
  • Database Independent Development using ASP.NET 2.0
  • Developing a common class which works with Factories: source code
  • Developing a common class which works with Factories: explanation
  • Developing a simple data access class to work with the factory: skeleton
  • Developing a simple data access class to work with the factory: methods
  • Developing a simple data access class to work with the factory: methods extended

  • 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


    Database Independent Development using ASP.NET 2.0 - Developing a simple data access class to work with the factory: methods extended


    (Page 6 of 6 )

    The following is the method which retrieves a single row in the form of a data row:

    Public Function GetDataRow(ByVal sqlSELECT As String) As DataRow
     
    Dim dt As DataTable = GetDataTable(sqlSELECT)
     
    If dt.Rows.Count > 0 Then
       
    Return dt.Rows(0)
     
    Else
       
    Return Nothing
     
    End If
    End Function

    The above function works with the previous GetDataTable function to return a set of rows. The following is the method which retrieves a single value in the form of a string from the database:

    Public Function GetValue(ByVal sqlSELECT As String) As String
     
    Dim cmd As DbCommand = GetDBCommand()
     
    cmd.CommandText = sqlSELECT
     
    cmd.CommandType = CommandType.Text
     
    Try
       
    cmd.Connection.Open()
       
    Return cmd.ExecuteScalar & ""
     
    Catch ex As Exception
       
    Throw New Exception(ex.Message & "-->" & sqlSELECT)
     
    Finally
       
    If cmd.Connection.State = ConnectionState.Open Then
         
    cmd.Connection.Close()
       
    End If
       
    cmd.Dispose()
      End Try
    End Function

    You can further enhance the above classes with the support of transactions, store procedures etc. You can find an ASP.NET application for testing along with the above classes as part of the free download.

    I hope you enjoyed the article and any comments, suggestions, feedback, bugs, errors, enhancements etc. are highly appreciated at http://jagchat.spaces.live.com


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hello guys! This is new series on database independent development using ASP.NET...
     

    ASP.NET ARTICLES

    - 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
    - Building a Simple Storefront with LINQ





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