473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Converting a generic Dataset to a typed dataset

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()
Nov 18 '05 #1
2 1365
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
Nov 18 '05 #2
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_DATASE T")

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

Brian Baker
--
Microsoft MVP -- ASP / ASP.NET
Please post responses to the group
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: David | last post by:
Can you convert a strongly typed dataset to another typed dataset if the schemas are identical? Thanks in advance for any insight. David.
7
by: Richard Myers | last post by:
Hello. I am getting an InvalidCastException which has revealed yet more of my ignorance. I cant believe i dont already know this and haven't encountered it before until now. I am consuming a...
3
by: Rakesh Rajan | last post by:
Hi, I have a method, which opens a connection, creates an untyped datable, fills it and returns it back. I have defined a typed datatable in my application as well. For some reasons, I have to...
2
by: Roy Rodsson via .NET 247 | last post by:
Hi all! I am using a stored procedure in SQL2000 for retrieving fileinformations from a db. the table as an uniqueidentifier for the file information. The stored procedure has a variable...
3
by: Freeon | last post by:
Hi, I am looking for a way to sort a strong typed dataset. It would seem the most straightforward way is to use a dataview. The only problem is when I use the dataview I seem to loose the strong...
4
by: Robert Bravery | last post by:
Hi All, I'm New to VS.net. Trying to figure out this new dataset thingy. Ok so I add a dataadapter with all the correct properties for a table. Then generate the dataset. Now open the dataset and...
9
by: Terry | last post by:
I am converting (attempting) some vb6 code that makes vast use of interfaces. One of the major uses is to be able to split out Read-only access to an obect. Let me give you a simple (contrived)...
9
by: Robert Bravery | last post by:
HI all, I have a column value returned to a string variable in my c# app. But the return type is of system.dbnull. How can I convert that to a system.sting Thanks Robert
9
by: mps | last post by:
I want to define a class that has a generic parameter that is itself a generic class. For example, if I have a generic IQueue<Tinterface, and class A wants to make use of a generic class that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.