net在oracle数据库中使用oracle

net在oracle数据库中使用oracle

本文介绍了使用c#.net在oracle数据库中使用oracle.managed.dataaccess.client插入excel批量数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要使用C#.net



使用Oracle.Managed.DataAccess.Client将包含n条记录的excel文件(datatable / dataset)上传到oracle数据库中我尝试过:



看起来托管数据访问不支持批量数据插入。但不确定是否可能有一些想法

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

推荐答案

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



这篇关于使用c#.net在oracle数据库中使用oracle.managed.dataaccess.client插入excel批量数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 13:05