Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Need to upload the excel file(datatable/dataset) contains n number of records into oracle database using Oracle.Managed.DataAccess.Client using C#.net

What I have tried:

It looks like Managed data access doesn't support Bulk data insert. But not sure whether there may be some ideas
Posted
Updated 5-Aug-16 1:13am
Comments
Foothill 5-Aug-16 13:23pm    
If you find an Oracle bulk insert, be sure to share it. If you don't, you could always multithread your insert process to make it happen a lot faster.

1 solution

Use this
C#
protected void btnUpload_Click(object sender, EventArgs e)  
{  
 try  
 {  
    if (fUpload.HasFile)  
     {  
        string Path = Server.MapPath(fUpload.FileName);  
        FillDatasetExcel(Path);  
     }  
 }  
 catch (Exception ex)  
 {  
   throw ex;  
 }  
}  
public DataTable FillDatasetExcel(string filepath)  
{  
  string path = filepath;  
  // Prepare cnnection string  
  string connectionstring =  
 @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties='Excel 12.0 Xml;HDR=YES;FMT=Delimited';";  
 byte[] Bytes = fUpload.FileBytes;  
  File.WriteAllBytes(path, Bytes);  
  OleDbConnection connection = new OleDbConnection();  
  connection.ConnectionString = connectionstring;  
  OleDbCommand command = new OleDbCommand();  
  command.CommandType = CommandType.Text;  
  command.Connection = connection;  
  command.CommandText = "Select * FROM [Sheet1$]";  
  connection.Open();  
  // create data table object  
  DataTable dt = new DataTable();  
  // Execute Reader and load the data into datatable  
  dt.Load(command.ExecuteReader());  
  // Close the connection  
  connection.Close();  
  return dt;  
}  
}  
 
Share this answer
 

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