Results 1 to 5 of 5

Thread: Query Method in Database Class

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Query Method in Database Class

    I am writting a database wrapper class (Heres most of the class) I have the db_open, db_state and db_close methods working properly...but now I want to create a db_query and a db_execute methods. I want the db_query to take 2 parameters, the first being a string (possible sql statement or stored procedure name) and the 2nd is a boolean value as to whether or not the first parameter is a stored procedure. But I am somewhat confused as to how to return the data?? I don't want to used a Dataset, because I don't want the recordset to be disconnected, so it is down to either a DataAdapter or a DataReader...obviously just to query (SELECT) records from the database the DataReader would be fine, but how to return the data to the user via a method call???

    I have seen methods like this
    Code:
    public Dataset blah(string blah)
    but haven't seen anything regarding how to do it with a DataAdapter or DataReader.

    Thanks!
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    Tadaaa

    It's the Microsoft Data Access Application Block - from the page blurb:
    The Data Access Application Block encapsulates performance and resource management best practices and can easily be used as a building block in your own .NET application. If you use it, you will reduce the amount of custom code you need to create, test and maintain.
    If I remember correctly, it uses DataReader exclusively.

  3. #3
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    It doesn't just use the datareader, it has ExecuteReader, ExecuteDataSet, ExecuteNonQuery, and ExecuteScaler functions. All of which are overloaded to provide the most functionality possible.

    I just want to add my vote for the Data Access Block. If you are accessing SQL Server, you really need to use this. It helps so much IMO.

    I think that they are updating it, or going to be updating it soon so you can call FillDataSet along with other features. Something to look out for.

  4. #4

  5. #5

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Hey, thanks for the links hellswraith!
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width