-
Jul 18th, 2011, 04:11 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Convert System.Object to datatable or Array
I'm pulling data from a D3 database, using an api.
The api can do the following:
Dim OBJ As Object = mvsp.MVResultSetGetRows.ToArray()
But how do I get that data into a datatable to use as the datasource for a DataGridView?
-
Jul 18th, 2011, 05:27 PM
#2
Re: Convert System.Object to datatable or Array
object is the universal datatype. to help you we need to know the actual type of array that this:
vb Code:
mvsp.MVResultSetGetRows.ToArray()
is returning
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 19th, 2011, 01:59 AM
#3
Thread Starter
Addicted Member
Re: Convert System.Object to datatable or Array
Originally Posted by .paul.
object is the universal datatype. to help you we need to know the actual type of array that this:
vb Code:
mvsp.MVResultSetGetRows.ToArray()
is returning
Hi Paul. The D3 database passed a flat file (1-dim array).
I fixed my problem by looping obj, split on delimiter and populating a datatable.
This will process about 600 000 records in under a second, that is quick enough for me.
Thanks a lot for trying to help Paul, I really appreciate the great help and attitude from the people on this forum. You guys have really been helpfull, thanks
-
Jul 19th, 2011, 02:01 AM
#4
Thread Starter
Addicted Member
Re: [RESOLVED] Convert System.Object to datatable or Array
vb Code:
Dim OBJ As Object = mvsp.MVResultSetGetRows.ToArray() Dim MyFields As String() = Split(MY_D3_Fields, " ") For i As Integer = 0 To MyFields.Length - 1 dt.Columns.Add(MyFields(i)) Next Dim Li = 0, cnt As Integer = OBJ.length Do Until Li = cnt Try Dim tmp As String() = Split(OBJ(Li).ToString, "þ") Dim cols As Integer = tmp.Length Dim v(cols - 1) As Object For c As Integer = 0 To cols - 1 v(c) = tmp(c) Next dt.Rows.Add(v) Catch ex As Exception End Try Li += 1 Loop MY_DT = New DataTable MY_DT = dt
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|