Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

I am stuck in serious issue I have implemented a fileupload functionality where user can upload .mdb file having 900000 rows record. I want to Import that .mdb file into mssql server database table.
When I am import .mdb file with having 100 records in. mdb file it imported successfully into MSSQL server table, But when I am import .mdb file having 900000 records it throws
error:"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."



I have used following code to import .mdb file:

C#
OleDbConnection excelConnection = null;
        OleDbCommand cmd = null;
         string excelConnectionString =
                @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Rakeshkumar\Uploads\test.mdb;Persist Security Info='False'";
     excelConnection = new OleDbConnection(excelConnectionString);

          //    cmd = new OleDbCommand("Select * from [test]", excelConnection);
             // cmd.CommandTimeout = 0;
          //  excelConnection.Open();
            OleDbDataAdapter da = new OleDbDataAdapter("Select * from [test]", excelConnection);
            DataTable ds = new DataTable();

            SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection);
            sqlBulk.WriteToServer(ds);
          excelConnection.Close();


Is this is a proper solution for import large Records(900000 rows) into MSsql server?If there any optimal solution pls tell me ASAP.
Posted

1 solution

Do the import in blocks of say 2000 records at a time.
 
Share this answer
 
Comments
nira.parmar 31-Aug-13 9:32am    
But How could it possible? pls tell me
Mehdi Gholam 31-Aug-13 9:35am    
If your test table has a primary key of say pid then you can do "select * from [test] where pid between 0 and 2000" for example.

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