473,385 Members | 2,015 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,385 software developers and data experts.

Converting DataSet to object type

I want to convert a dataset to type object so I can pass it to a generalized
function which accepts an object and adds it to the cache.

If I pass it in like:
Convert.ChangeType(MyDataSet, typeof(object))
or
(object)Convert.ChangeType(MyDataSet, typeof(object))

I get an InvalidCastException, with a message of Object must implement
IConvertible.

System.Data.DataSet doesn't implement IConvertible. Is there another way to
cast the DataSet as an object?


Nov 18 '05 #1
1 1958
You don't need to convert or cast anything. If you have a function that
accepts Object then it will accept DataSet as well since DataSet inherits
from Object (as all other objects do).

If you insist however on explicit casting, this will do:
VB:
dim o as Object = MyDataSet
C#:
Object o = (Object) MyDataSet
"George Durzi" <gd****@hotmail.com> wrote in message
news:eG**************@TK2MSFTNGP09.phx.gbl...
I want to convert a dataset to type object so I can pass it to a generalized function which accepts an object and adds it to the cache.

If I pass it in like:
Convert.ChangeType(MyDataSet, typeof(object))
or
(object)Convert.ChangeType(MyDataSet, typeof(object))

I get an InvalidCastException, with a message of Object must implement
IConvertible.

System.Data.DataSet doesn't implement IConvertible. Is there another way to cast the DataSet as an object?

Nov 18 '05 #2

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

Similar topics

1
by: Rohit D via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Rohit D Hi All, I have a dataset and want to write a standard code in vb.net forconverting that dataset to an heirarchical...
3
by: Lerp | last post by:
Hi all, What's the syntax for creating a row out of the current item in a datagrid? Something like this ? Dim myRow as DataRow = mydataGrid.DataKeys(e.item.itemindex)
3
by: Mae | last post by:
Dear All, I have a problem here, I'm using C# Webform calling a webservices. The webservices return me a XMLnode, using this XMLnode I want to convert it to dataset so I can bind to the...
1
by: Ramakrishnan Nagarajan | last post by:
Hi, I am converting Excel data into a Dataset in C#. There are around 24 columns in the Excel Sheet. First I tried to insert one row with correct values in the Excel sheet. i.e. for text columns...
6
by: Ramakrishnan Nagarajan | last post by:
Hi can any one help me in converting a DataView into a DataSet or a DataTable into a DataSet, I tried the following ways dSet= ((DataSet)_gridRegStudDetails.DataSource); dSet =...
3
by: Parvesh | last post by:
hi, I am using a webservice which Returns the Result in an XML string, The XML response i get i svery cumbersome to parse, But if i could convert it to the Corresponding Class using the...
1
by: J. Askey | last post by:
I am implementing a web service and thought it may be a good idea to return a more complex class (which I have called 'ServiceResponse') in order to wrap the original return value along with two...
1
by: matt | last post by:
hello, i have a web app that allows users to query our oracle db and produce a dataset of report data. they then have the option to serialize this data and store it in the database. later, then...
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
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.