uploading large amount of text file [Resolved]

Posted by Hemali under ASP.NET on 2/2/2012 | Points: 10 | Views : 2261 | Status : [Member] | Replies : 3
Hello,
My question is :
How to upload large amount of data in text file format in asp.net using C# and important requirement is that after uploading 1000 records it gets refresh itself and fetch next 1000 records and so on... Pls pls help me...




Responses

Posted by: Ogipansrk on: 2/5/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
You should write a recursive method...
Beow is a sample code , which gives a baisc idea.

Void ReloadDataFromDataBase(int num)
{
DataSet ds=null;
if(num==0)
ds= FetchDataFromThisRecord(num)
Else
ds= FetchDataFromThisRecord(num)
using (var writer = new StreamWriter("foo.txt"))
{
private int counter=0; // set the 1000 counter value
if(ds !=null )
{
foreach(var data in ds.tabels[0].rows)
{
// loop through your dataset ...depending on your requirement
//before writing data to file check
if(counter > 1000)
ReloadDataFromDataBase(counter); // pass the counter counter value when it reaches 1001...
// Write your data here
writer.Write("{0:0.0} ", i);
}

}
}
}

Hemali, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ogipansrk on: 2/8/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
What I understood iz , you are writing some content to flat file.
And uploading that file on daily basis.

1. As you are uploading file on daily basis , it is better to name csv file on date basis.
2. Alternatively , if you want to use same file , then check if file exists , if
there is already a file , then append data to it , else create a new file.

note: flat file supports data only to some extent.

Hemali, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hemali on: 2/8/2012 [Member] Starter | Points: 25

Up
0
Down
Hey Thanx for d help..
Now m having another problem i.e in other project i m importing file through schema.ini file that creates dynamic table and insert the lakhs of record in few seconds bt now problem is that i have to upload that file at the end of day everyday bt when i upload same csv file second time obviously it generates error saying table alredy exits... What is another way than this???
Pls pls hepl me...

Hemali, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response