Click here to Skip to main content
11,716,249 members (90,929 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0 MS-Access
I have to insert large text file(10,000 lines) in access database field (coloum).But the problem is when i insert large there is data shifting.
i.e when i check the original file with the file i have inserted in database , data is not inserted sequentially. but same code works with small text file.

Here is the code for inserting file in database

private void insert(object sender, EventArgs e)
{

try
{
con = new OleDbConnection(@"Provider = Microsoft.JET.OLEDB.4.0;data source =EDMDatabase.mdb;Jet OLEDB:Database password =;");
con.Open();

file2 = new StreamReader(Application.StartupPath + "\\" + "FLEXPMAC.DAT");

while (file2.EndOfStream==false)
{
string setupstr1 = null;

if (file2.ReadLine() != null)
setupstr1 = file2.ReadLine();


//Inserting text file in database(EDMDatabase.mdb) table(ex) column(xyz)

cmd = new OleDbCommand("insert into ex (xyz) values('" + setupstr1 + "')", con);

cmd.ExecuteNonQuery();
}

}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

Please help...where i can find the anwer..and thanxs in advance.
Posted 20-Nov-12 19:06pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 664
1 Maciej Los 340
2 Richard MacCutchan 280
3 F-ES Sitecore 215
4 OriginalGriff 160
0 Sergey Alexandrovich Kryukov 1,003
1 Richard MacCutchan 430
2 CHill60 415
3 Maciej Los 399
4 OriginalGriff 385


Advertise | Privacy | Mobile
Web03 | 2.8.150901.1 | Last Updated 21 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100