dataset to array

G

Guest

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
 
P

pvdg42

chieko said:
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?
 
G

Guest

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top