Click here to Skip to main content
15,897,718 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900