// Connection String to Excel Workbook
string excelConnectionString = @"Provider=Microsoft
    .Jet.OLEDB.4.0;Data Source=Book1.xls;Extended
    Properties=""Excel 8.0;""
";

// Create Connection to Excel Workbook
using (OleDbConnection connection =
            
new OleDbConnection(excelConnectionString))
{
    OleDbCommand command
= new OleDbCommand
            (
"Select ID,Data FROM [Data$]", 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
        using (SqlBulkCopy bulkCopy =
                  
new SqlBulkCopy(sqlConnectionString))
        {
            bulkCopy.DestinationTableName
= "ExcelData";
            bulkCopy.WriteToServer(dr);
        }
    }
}
Posted by xhoto

카테고리

분류 전체보기 (125)
日常茶飯事 (28)
明日があるさ (1)
ThinkWise (0)
Etc (12)
hidden (5)
Sinclair (0)
Through the Viewfinder (1)
I'm Developer (78)

최근에 받은 트랙백

달력

«   2009/01   »
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31