Upload Excel To MS SQL Server 2005

Dear Aspose's MVPs...

Please give me some sample of codes to upload excel file to Ms Sql Server 2005 using vb.net in web application..

Regards,

Didik Setiawan

Senior .Net Programmer

Adira Dinamika Multi Finance - Jakarta, Indonesia

Hi,

Thank you for considering Aspose.

Following is the sample code which exports the data from Excel to SQL Server 2005 database.

Sample Code:-

Dim workbook As Workbook = New Workbook()
workbook.Open("F:\\Excels\bookLoad.xls")
Dim worksheet As Worksheet = workbook.Worksheets(0)
Dim dataTable As DataTable = New DataTable()
'Export worksheet data to a DataTable object by calling either ExportDataTable or ExportDataTableAsString method of the Cells class
dataTable = worksheet.Cells.ExportDataTable(0, 0, worksheet.Cells.MaxRow + 1, worksheet.Cells.MaxColumn + 1, True)
Dim connectionString As String = "Data Source=(local);Initial Catalog=myDataBase;Integrated Security=SSPI;"
Dim conn As SqlConnection = New SqlConnection(connectionString)
Dim Adapter As SqlDataAdapter = New SqlDataAdapter()
' Dim command As SqlCommand = New SqlCommand("INSERT INTO Employee VALUES(@param1, @param2)", conn)
Adapter.SelectCommand = New SqlCommand("Select * From Employee", conn)
Adapter.InsertCommand = New SqlCommand("INSERT INTO Employee VALUES(@param1, @param2)", conn)
Adapter.InsertCommand.Parameters.Add("@param1", SqlDbType.NVarChar, 1000, "EmployeeName")
Adapter.InsertCommand.Parameters.Add("@param2", SqlDbType.NVarChar, 1000, "EmployeeDate")
Adapter.Fill(dataTable)
Adapter.Update(dataTable)

Thank you & Best Regards,