none
SQLHelper Class with C#.NET

    Question

  • Hello Friends,
    I'm using SQLHelper class with my C#.NET applications. So far the class is very useful for me to handle data insert/update/delete operations efficiently. I'm a newbie to C# and OOP. Please some expert tell me your ideas about this sqlhelper class. These are my questions.
    1) is it a good practice to use the sqlhelper class with C#.NET oop programming?
    2) what are the disadvantages of using this sqlhelper class?
    3) can we use the sqlhelper class with .NET 3.0 and beyond versions. I mean does the Microsoft    provide additions to this class?
    Thanks in advance!
    sithira.

    • Edited by Sithira Sunday, September 14, 2008 6:31 AM
    Sunday, September 14, 2008 6:28 AM

Answers

  • 3: AFAIK there are no significant changes with .NET 3.0/3.5 [inc. SP1 for each]. The big change with .NET 3.5 is LINQ: 3.5 includes LINQ-to-SQL, and 3.5 SP1 includes LINQ-to-Entity-Framework. These can be used to radically overhaul your approach to data.

    (1/2: don't know: I've never used it...)

    Marc
    • Marked as answer by jack 321 Wednesday, September 17, 2008 6:45 AM
    Sunday, September 14, 2008 8:54 AM
  • using a helper doesn't exclude OOP however the helper itself is probably very procedural in nature.

    Generally there's the SRP (single responsibility principle) that states your object should have only one responsibility. If yours is doing insert, update, AND delete it's already doing multiple things. Additionally, if it's doing it for multiple types of tables that compounds the numerous things it does. Then just by it's name i'm going to guess that it uses SQL server which adds a little more issue to OOP because you're probably not thinking about the Inversion Principle... meaning your objects should never depend on the implementation only on the abstraction.

    For example.

    you should probably write something like this:
    CustomerRetriever->SQLCustomerRetriever
                                    OracleCustomerRetriever
                                     XMLCustomerRetriever

    CustomerUpdater->SQLCustomerUpdater
                                     OracleCustomerUpdater
                                       XMLCustomerUpdater

    and so on.

    also you could use generics to then do something like this

    Retriever<T> -> SQLRetriever<T>

    where you'd do something like this:

    class CustomerRetriever : Retriever<Customer> {}

    If you want to get a good OOP way to handle data access (in my opinion) check out enterprise library data access application block. It's pretty cool.


    http://www.jamespeckham.com
    • Edited by James Peckham Sunday, September 14, 2008 10:38 PM
    • Marked as answer by jack 321 Wednesday, September 17, 2008 6:46 AM
    Sunday, September 14, 2008 10:36 PM

All replies

  • 3: AFAIK there are no significant changes with .NET 3.0/3.5 [inc. SP1 for each]. The big change with .NET 3.5 is LINQ: 3.5 includes LINQ-to-SQL, and 3.5 SP1 includes LINQ-to-Entity-Framework. These can be used to radically overhaul your approach to data.

    (1/2: don't know: I've never used it...)

    Marc
    • Marked as answer by jack 321 Wednesday, September 17, 2008 6:45 AM
    Sunday, September 14, 2008 8:54 AM
  • Thank you Marc Gravell! for the answer3.
    • Edited by Sithira Sunday, September 14, 2008 10:55 AM
    Sunday, September 14, 2008 10:54 AM
  • using a helper doesn't exclude OOP however the helper itself is probably very procedural in nature.

    Generally there's the SRP (single responsibility principle) that states your object should have only one responsibility. If yours is doing insert, update, AND delete it's already doing multiple things. Additionally, if it's doing it for multiple types of tables that compounds the numerous things it does. Then just by it's name i'm going to guess that it uses SQL server which adds a little more issue to OOP because you're probably not thinking about the Inversion Principle... meaning your objects should never depend on the implementation only on the abstraction.

    For example.

    you should probably write something like this:
    CustomerRetriever->SQLCustomerRetriever
                                    OracleCustomerRetriever
                                     XMLCustomerRetriever

    CustomerUpdater->SQLCustomerUpdater
                                     OracleCustomerUpdater
                                       XMLCustomerUpdater

    and so on.

    also you could use generics to then do something like this

    Retriever<T> -> SQLRetriever<T>

    where you'd do something like this:

    class CustomerRetriever : Retriever<Customer> {}

    If you want to get a good OOP way to handle data access (in my opinion) check out enterprise library data access application block. It's pretty cool.


    http://www.jamespeckham.com
    • Edited by James Peckham Sunday, September 14, 2008 10:38 PM
    • Marked as answer by jack 321 Wednesday, September 17, 2008 6:46 AM
    Sunday, September 14, 2008 10:36 PM
  •  The best way is to use Microsoft.SqlClient.Management.Smo object. It is Linq compatible.
    AlexB
    Monday, September 15, 2008 12:54 AM
  • the best way to skin a cat is to use a tater peeler.
    http://www.jamespeckham.com
    Monday, September 15, 2008 1:00 AM
  • hello friends,

          i want to use sqlhelper class but i dnt have any idea regarding this as how to use it  and how to add it to our project . plz guide me regarding this.

    Tuesday, April 13, 2010 9:13 AM
  • I have a question , Do you know where the SqlHelp class to download ? Can you give me a link tip to download it ,I want to try it .
    Friday, July 15, 2011 7:08 AM
  • Here is a good one.

    http://www.blackbeltcoder.com/Articles/ado/an-ado-net-sql-helper-class

     

     

    Monday, November 28, 2011 9:27 PM