当我从 csv 插入数据时;描述列数据被截断,长度为 255。
尝试描述 varchar(max)、nvarchar(max)、text 等的数据类型。
我的代码
string CsvConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +filelocation +"; Extended Properties=\"text;HDR=Yes;FMT=Delimited\"";
using (OleDbConnection connection = new OleDbConnection(excelConnectionString))
{
OleDbCommand command = new OleDbCommand("Select * FROM ["+filename+"]", connection);
connection.Open();
using (DbDataReader dr = command.ExecuteReader())
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString))
{
bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping("description", "description"));
bulkCopy.DestinationTableName = "Table1";
bulkCopy.WriteToServer(dr);
}
}
VS2010, C# SQL2008 R2 10.50 Express
请建议是否有其他方法可以将数据从 CSV 插入 SQL Server