Converting a generic Dataset to a typed dataset

Discussion in 'ASP .Net' started by William Gower, Jul 26, 2004.

  1. I have a method called RetrieveAll that returns a Dataset

    The object that is calling this method expects to receive a UserDS. I don't
    want the RetrieveAll to have to know about the UserDS but just return a
    dataset and the calling method will convert it to a specific typed dataset.
    How do I do this?

    Dim dalc as New UserDALC
    Dim user As New UserDS
    user = dalc.RetrieveAll()
     
    William Gower, Jul 26, 2004
    #1
    1. Advertising

  2. On 7/25/2004 11:43 PM, William Gower wrote:
    > I have a method called RetrieveAll that returns a Dataset
    >
    > The object that is calling this method expects to receive a UserDS. I don't
    > want the RetrieveAll to have to know about the UserDS but just return a
    > dataset and the calling method will convert it to a specific typed dataset.
    > How do I do this?
    >
    > Dim dalc as New UserDALC
    > Dim user As New UserDS
    > user = dalc.RetrieveAll()
    >
    >

    Does the dalc class have a .Fill method of some sort? To be honest, any
    data access layer object I create that 'returns data' has this, as alot
    of times a caller may ask to fill an existing structure, instead of
    always getting a newly-created return structure. Then you could just
    create a typed dataset in the above code and pass to the dalc.Fill(..)
    method...

    Otherwise you'd pry have to write some utility to copy the data and
    structures from one DataSet to the other...

    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET
     
    Craig Deelsnyder, Jul 26, 2004
    #2
    1. Advertising

  3. William Gower wrote:
    > I have a method called RetrieveAll that returns a Dataset
    >
    > The object that is calling this method expects to receive a UserDS. I
    > don't want the RetrieveAll to have to know about the UserDS but just
    > return a dataset and the calling method will convert it to a specific
    > typed dataset. How do I do this?


    Here is what I did in a similar situation:

    -------------------------------------
    Dim ds as Dataset
    Dim dsTyped as myTypedDataset

    ds = DAL.GetDataSetSP("procname")
    ds.Tables(0).TableName("TABLE_NAME_IN_TYPED_DATASET")

    dsTyped.Merge(ds)
    -------------------------------------

    Brian Baker
    --
    Microsoft MVP -- ASP / ASP.NET
    Please post responses to the group
     
    Brian Baker [MVP], Jul 26, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nedu N
    Replies:
    1
    Views:
    1,838
    Chris Taylor
    Oct 31, 2003
  2. Nedu N
    Replies:
    2
    Views:
    2,207
  3. Ersin Gençtürk
    Replies:
    1
    Views:
    3,550
    Ersin Gençtürk
    Oct 6, 2004
  4. Yingjie Lan
    Replies:
    4
    Views:
    340
    John Nagle
    Jan 29, 2010
  5. Alex Maskaev

    Typed DataSet and converting types

    Alex Maskaev, May 26, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    148
    Jan Tielens
    May 26, 2004
Loading...

Share This Page