PDA

View Full Version : Error در انتقال داده از Excel به SQL



Bidel_barnamenevis
پنج شنبه 28 آبان 1388, 11:24 صبح
سلام;
برای انتقال داده از Excel به SQL کد زیر را نوشتم.

// Connection String to Excel Workbook
string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:Book1.xlsx;Extended Properties="" Excel 12.0;HDR=YES;""";
// Create Connection to Excel Workbook
using (OleDbConnection connection = new OleDbConnection(excelConnectionString))
{
OleDbCommand command = new OleDbCommand("Select ID,Data FROM [sam$]", connection);
connection.Open();
// Create DbDataReader to Data Worksheet
using (DbDataReader dr = command.ExecuteReader())
{
// SQL Server Connection String
// string sqlConnectionString = "Data Source=.; Initial Catalog=Test;Integrated Security=True";
// Bulk Copy to SQL Server
if (ADOClass.GetActiveConnection(ref con))
{
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(con))
{
bulkCopy.DestinationTableName = "ExcelTest";
bulkCopy.WriteToServer(dr);
}
}
}

و این Error را میده!!
System.Data.OleDb.OleDbException: Could not find installable ISAM.
ممکنه راهنماییم کنید ؟!
ISAM به microsoft Office مربوطه؟؟