Move Array To Table

P

Peter

VS 2003 .NET 1.1

What is the fastest way to move 2 dimensional Array of objects into a
DataTable, besides using a loop?
I have a about 30,000 elements in my array and I have to move it into a
DataTable

Thank You



Peter
 
G

Guest

Peter,
Basically you need to keep doing DataTable.NewRow, so I don't think there is
an alternative. e.g. (pseudocode):

DataRow row;
foreach(item in myArray)
{
row=MyTable.NewRow();
row.ItemArray= item // assuming they match the columns, or whatever
MyTable.Rows.Add(row);
}

--Peter



}
 
J

Jeffrey Tan[MSFT]

Hi Peter,

Thanks for your post!

I agree with pbromberg that .Net FCL does not provide interface to import 2
dimensional array into DataTable. You have to loop through the Array to add
them row by row.

Yes, I see that there are a lot of elements in the array, so the importing
may have some impact on the performance. I think you'd better use certain
type of delay import in the design to reduce the performance impact. For
example, you seldom display all the elements in the GUI, so you may paging
all the elements in several sections, and import and display one section at
a time.

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Peter,

Does reply make sense to you? Do you still have any concern regarding it?
Please feel free to tell me, thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter

"Jeffrey Tan[MSFT]" said:
Hi Peter,

Does reply make sense to you? Do you still have any concern regarding it?
Please feel free to tell me, thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.


I have found a solution at
http://www.codeproject.com/cs/database/BindArrayGrid.asp where you can move
2 dimensional array to DataGrid, unfortunately I can not figure out how to
change the GridColumnStyle so I can format individual cells. I have asked
the author "How do I apply column styles to a DataGrid that uses
ArrayDataView instead of DataSet", but he does not respond.

Even though I am displaying only 10 by 20 grid (10 rows by 20 columns) I
have to give the user an ability to scroll to any part of the table very
fast and this table might contain up to 7,000 columns so I can not put this
into Access Table.


Thank you


Peter
 
J

Jeffrey Tan[MSFT]

Hi Peter,

Have you tried my sample project? Does it meet your need? Please feel free
to tell me, thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter

"Jeffrey Tan[MSFT]" said:
Hi Peter,

Have you tried my sample project? Does it meet your need? Please feel free
to tell me, thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

What sample project are you referring to?
 
J

Jeffrey Tan[MSFT]

Hi Peter,

I have added a reply to you in Tue, 04 Jul 2006. I performed some search in
google and found that it is missed in groups.google.com, so I suspect it is
missed in the newsgroup, however, I still can see it in our internal suppor
tool. Anyway, I will paste that reply here:

"Hi Peter,

Thanks for your feedback!

DataGrid does not support formatting for individual cells, it can only
apply formatting at column level with DataGridTextBoxColumn.Format and
FormatInfo properties.

To customize ArrayDataView for supporting DataGridTextBoxColumn, I have
provided you some guide line in the link below:
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/msg/
363eb3e9931a4041?hl=zh-CN&

To demonstrate my statement, I have modified that project regarding the
guide I provided. In the sample project, I set
DataGridTextBoxColumn.Format="c", so that all the cells will display
currency style of value.

I have attached my modified sample project in this reply. You can download
it with Outlook Express, not IE.

I am not sure I understand your second completely. Why do you mention
"Access Table"? I did not suggest you put the data in "Access Table". What
I was suggestion is that: since your data is huge, if you are binding all
the data with DataGrid, the initial databinding and displaying time will be
significant long, which gives the end user a not good experience on your
application. So it is better to introduce certain type of paging in
databinding. That is divide all your data into several sections, and only
bind 1 section of data with DataGrid, and provide another "Next Page"
button for the user, which will load next section of data and bind with the
DataGrid for displaying. This will improve the performance and GUI
significantly.

Anyway, if you have good reason to not use paging, you can remain the
current design.

Hope this helps!"

Regarding the sample project, you may send an email to me, I will send you
that project. You may contact me at: (e-mail address removed)(remove
"online.")

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Peter,

Have you reviewed my last reply? Does it make sense to you? If you want,
please feel free to email me, I will send you the sample project. Thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter

"Jeffrey Tan[MSFT]" said:
Hi Peter,

Have you reviewed my last reply? Does it make sense to you? If you want,
please feel free to email me, I will send you the sample project. Thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

What sample project are you referring to? (I don't see one)
 
J

Jeffrey Tan[MSFT]

Hi Peter,

Thanks for your feedback!

I have sent an email to you with the attachment. Please check it in your
mailbox and feedback any comment here. Thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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