473,385 Members | 1,356 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,385 software developers and data experts.

Best approach to filling table and loading to grid? Please help...

VM
If I wanted to load an ascii file (which contains 400,000+ lines and each
line is a table row) to a datatable and then display it to a datagrid, what
would the best approach be? I initially had a method that would fill the
table with the ascii file data (the parm was the fileName), it would return
the filled datatable, and then I'd use it as a datasource for the grid. That
was working well with small files but the client just told me that files
would normally contain between 400K-800K rows. So with my layout, the user
would have to wait until the method processes the whole file and attaches
the file to the grid before he/she can see anything. Is there a more
efficient way of doing it? Is there any way I can display some of the
records while the rest is being processed? My only concern there is what
datagrid event to use so I know that the user wants to look at more rows.
The other way I tried is by using delegates and instead of returning a
datatable it'll return a datarow. Unfortunately, it still turns out to be
very slow and its performance doesn't seem correct...

loadFileDelegate LoadAuditFileToTable = new
loadFileDelegate(loadAuditFileToTable);
BeginInvoke (LoadAuditFileToTable, new object[] { sFileName});
loadAuditFileToTable(sFileName);

private void loadAuditFileToTable(string sFileName)
{
DataRow rowAudit;
ZMMatch.Audit zmAudit = new ZMMatch.Audit();
_table_auditAddress = zmAudit.openAZM(sFileName); //Opens ascii file and
prepares datatable
//dataGrid_auditAddress.DataSource = _table_auditAddress;
bool isEndOfFile=false;
while (!isEndOfFile)
{
rowAudit = zmAudit.readAuditAZMFileToView(ref isEndOfFile, ref
iRowsProcessed); //it reads one line and converts to row
if (!isEndOfFile)
{
_table_auditAddress.Rows.Add(rowAudit);
ShowProgress();
}
}
delegate void ShowProgressDelegate();
private void ShowProgress()
{
if(dataGrid_auditAddress.InvokeRequired == false )
{
dataGrid_auditAddress.DataSource = _table_auditAddress;
//dataGrid_auditAddress.Refresh();
//Application.DoEvents();
}
else
{
ShowProgressDelegate showProgress = new
ShowProgressDelegate(ShowProgress);
BeginInvoke(showProgress, new object[] { });
}

}

Any help is appreciated since I'm really stuck with this and it's due Thurs.
morning...
Nov 16 '05 #1
0 1151

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

Similar topics

2
by: Laphan | last post by:
Hi All I know the subject sounds strange, but please bear with me. Using ADO/ASP, I want to retrieve a list of pics from my db (which will be dynamic number of pics as a user will be uploading...
12
by: Aaron Smith | last post by:
What is the best way to handle data in a multiple user environment? We have forms that will allow users to add edit and delete data from a table on SQL server. The data could be edited on multiple...
1
by: Jeff User | last post by:
Hello all I need to build a web form that will allow user to enter database table column definitions. Each row on the form would contain column name, data type (chosen from a drop down list), size...
2
by: Jeff User | last post by:
Hello all I need to build a web form that will allow user to enter database table column definitions. Each row on the form would contain column name, data type (chosen from a drop down list), size...
4
by: Tarun Mistry | last post by:
Hi all, I have posted this in both the c# and asp.net groups as it applies to both (apologies if it breaks some group rules). I am making a web app in asp.net using c#. This is the first fully OO...
2
by: Bob | last post by:
I got three related datagrid views one parent and two children of the same. The two child tables contain many thousands of records and some of the contents are bitmap files in a sql server...
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
2
by: VMI | last post by:
I'm filling up a gridview and the underlying datatable has about 30,000 records, so it takes some time before I can see the page again with the records on the gridview. Is there any type of...
2
by: VMI | last post by:
I'm filling up a gridview and the underlying datatable has about 30,000 records, so it takes some time before I can see the page again with the records on the gridview. Is there any type of...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.