Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("TERAMSConnectionString").ConnectionString) Dim path As String = FileUpload1.PostedFile.FileName Dim excelConnectionString As String = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + (path + ";Extended Properties=Excel 12.0;Persist Security Info=False")) Dim excelConnection As OleDbConnection = New OleDbConnection(excelConnectionString) conn.Open() excelConnection.Open() Dim cmd As OleDbCommand = New OleDbCommand("Select * from [Sheet1$]", excelConnection) 'Clears any previous data Dim sClearSQL = "DELETE FROM Desktop_Compare " Dim SqlCmd As SqlCommand = New SqlCommand(sClearSQL, conn) SqlCmd.ExecuteNonQuery() Dim dReader As OleDbDataReader = cmd.ExecuteReader Dim sqlBulk As SqlBulkCopy = New SqlBulkCopy(conn) excelConnection.Close() conn.Close() End Using
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)