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

dataset to array

Hello,
I'd like to know why the copyto method in the System.DataRowCollection
does not copy the dataset to an array using the following syntax:
Thanks,
Chieko

Dim ds As New DataSet
Dim da As New SqlDataAdapter
dim State() as String

Try
da.SelectCommand = cmd
da.Fill(ds)
Dim howmany As Integer = ds.Tables(0).Rows.Count()
ds.Tables(0).Rows.copyto(State, 0)
Return State
Catch ex As Exception
console.writeline(ex.Message)
End Try
conn = Nothing
cmd = Nothing
Mar 16 '07 #1
3 5169

"chieko" <ch****@discussions.microsoft.comwrote in message
news:13**********************************@microsof t.com...
Hello,
I'd like to know why the copyto method in the System.DataRowCollection
does not copy the dataset to an array using the following syntax:
Thanks,
Chieko

Dim ds As New DataSet
Dim da As New SqlDataAdapter
dim State() as String

Try
da.SelectCommand = cmd
da.Fill(ds)
Dim howmany As Integer = ds.Tables(0).Rows.Count()
ds.Tables(0).Rows.copyto(State, 0)
Return State
Catch ex As Exception
console.writeline(ex.Message)
End Try
conn = Nothing
cmd = Nothing
It would help narrow down the possibilities if you could post the exact
error or exception message you get.
Guessing, the first thing that strikes me is your attempt to implicitly cast
a DataRow object to a String.
Have you tried using the DataRow class ToString() method to perform the
conversion before storing in your array of String?
Mar 16 '07 #2
VJ
You array is not sized??
VJ

"chieko" <ch****@discussions.microsoft.comwrote in message
news:13**********************************@microsof t.com...
Hello,
I'd like to know why the copyto method in the System.DataRowCollection
does not copy the dataset to an array using the following syntax:
Thanks,
Chieko

Dim ds As New DataSet
Dim da As New SqlDataAdapter
dim State() as String

Try
da.SelectCommand = cmd
da.Fill(ds)
Dim howmany As Integer = ds.Tables(0).Rows.Count()
ds.Tables(0).Rows.copyto(State, 0)
Return State
Catch ex As Exception
console.writeline(ex.Message)
End Try
conn = Nothing
cmd = Nothing


Mar 16 '07 #3
Hello,
Thanks for helping
The error message is Arra cannot be null parameter : dest
I thought the toString function converted the name of the dataRow to a
string, not the contents.
Chieko
"pvdg42" wrote:
>
"chieko" <ch****@discussions.microsoft.comwrote in message
news:13**********************************@microsof t.com...
Hello,
I'd like to know why the copyto method in the System.DataRowCollection
does not copy the dataset to an array using the following syntax:
Thanks,
Chieko

Dim ds As New DataSet
Dim da As New SqlDataAdapter
dim State() as String

Try
da.SelectCommand = cmd
da.Fill(ds)
Dim howmany As Integer = ds.Tables(0).Rows.Count()
ds.Tables(0).Rows.copyto(State, 0)
Return State
Catch ex As Exception
console.writeline(ex.Message)
End Try
conn = Nothing
cmd = Nothing
It would help narrow down the possibilities if you could post the exact
error or exception message you get.
Guessing, the first thing that strikes me is your attempt to implicitly cast
a DataRow object to a String.
Have you tried using the DataRow class ToString() method to perform the
conversion before storing in your array of String?
Mar 16 '07 #4

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

Similar topics

4
by: Simon | last post by:
Hi all, I have a process, where I take a dataset from an SQL call, and need to write an XML file from that dataset. The data set can contain 10's of tables, each with 100's of rows, and I have...
1
by: David D. McCrory | last post by:
I have the following that returns an array of a struct and I want to load it into a DataSet on the consumer side.....Can someone provide me with an example of how to use the DataSet.ReadXml()...
2
by: Marty McDonald | last post by:
I have an array of objects (my own custom class). I'm trying to convert that array to a dataset. So I serialize the array to XML, then try to load the XML to a dataset. MemoryStream mem = new...
1
by: STeve | last post by:
Hi guys, I was wondering how I would go about creating a string array from a single column from a dataset. What I was thinking was iterate through each row in the dataset, finding out the size...
5
by: Trond | last post by:
I have a webservice that is returning a dataset. In dataset there is a table with 4 columns. (LDate, LTime, LDepth and ServiceNumber) I then try to read only 2 of the columns into array (double...
5
by: moondaddy | last post by:
I'm caching a dataset in an asp.net session variable to hold a user's data. one data item I need to store is an image the user uploaded. My problem is that I don't know how to get the image into...
12
by: Graham Blandford | last post by:
Hi all, Would someone be able to tell me the most 'graceful' way of removing unwanted rows from a dataset based on a condition prior to update? OR, resetting the rows all to unchanged after they...
7
by: Bob | last post by:
Hi, I have a typed unbound dataset that is passed to a datahandling class to be filled. The datahandling class fills it from a sproc using an oledbDataAdapter (SQLAnywhere database) The only...
1
by: TiGeR79 | last post by:
Hello, I've written a webservice which returns a dataset containing just one table with two columns. One colum holds a string while te second holds an image serialized into a byte array. This...
0
by: OscarPiacenza | last post by:
Hello all. :) My name is Oscar and I’m a novice on XML and dataset arguments. I need some help to resolve (and understand :) ) the following problem: I have stored some data in a SqlServer...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.