sqlbulkcopy from Excel via ACE.OLEDB truncates text to 255 chars

前端 未结 1 1047
深忆病人
深忆病人 2021-01-23 23:07

Pretty straight-forward import using SqlBulkCopy:

string excelConnectionString = @\"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\" + filePath + \";Extended Pro         


        
1条回答
  •  清酒与你
    2021-01-24 00:13

    I used ODBC instead of the OLEDB and it doesn't truncate the values to 255 symbols anymore:

    OdbcConnection con = new OdbcConnection(@"Driver={Microsoft Excel Driver
    (*.xls)};DBQ=c:\temp\testbook.xls");
    OdbcCommand cmd = new OdbcCommand(@"SELECT * FROM [Workbook1$]");
    cmd.Connection = con;
    OdbcDataAdapter da = new OdbcDataAdapter(cmd);
    DataSet ds = new DataSet();
    da.Fill(ds);
    

    you can use 2007 format driver to access XLSX files: .... Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)}

    0 讨论(0)
提交回复
热议问题