My excel data are sorted but why when I import into sql server, they are not sorted :-( why???? Pls help
Thanks alot
VB.NET:
Dim ExcelConnection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Book2.xlsx; Extended Properties=""Excel 12.0 Xml; HDR=Yes""")
ExcelConnection.Open()
Dim expr As String = "SELECT * FROM [Sheet1$] order by month_year, emp_id"
Dim objCmdSelect As OleDbCommand = New OleDbCommand(expr, ExcelConnection)
Dim objDR As OleDbDataReader
Using bulkCopy As SqlBulkCopy = New SqlBulkCopy(sqlconn)
bulkCopy.DestinationTableName = "tblPayroll_prev"
Try
objDR = objCmdSelect.ExecuteReader
bulkCopy.WriteToServer(objDR)
objDR.Close()
sqlconn.Close()
GetData_prev(da2.SelectCommand.CommandText)
sqlconn.Close()
MessageBox.Show("Import successful for " + mnth + "!")
Catch ex As Exception
MsgBox(ex.ToString)
sqlconn.Close()
End Try
End Using
Thanks alot