dataset to array

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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?
 
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
 
Back
Top