Hi Guys, I'm having troubling with my application to get data from an excel file, save it to a CSV, and export it over to a DB.

First Problem, Excel doesn't seems to close after i convert xls to csv.

Second problem i need to concat the last two columns of the CSV file to obtain a timestamp of the data as of the xls.

This is my coding so far

VB Code:
  1. Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
  2.  
  3.         Dim xlApp As Excel.Application
  4.         Dim xlBook As Excel.Workbook
  5.         Dim xlSheet As Excel.Worksheet
  6.         Dim xlformat As Excel.XlFileFormat = Excel.XlFileFormat.xlCSV
  7.         Dim c As New CSV_TO_DATA_TABLE.CSV_CONVERT.CSV_TO_DATA_TABLE
  8.         Dim dt As DataTable
  9.  
  10.         xlApp = CreateObject("Excel.Application")
  11.         xlBook = xlApp.Workbooks.Open("C:\Program Files\STOCK TAKE SYSTEM\STS.XLS")
  12.         xlBook.SaveAs("C:\Program Files\STOCK TAKE SYSTEM\STS.CSV", FileFormat:=xlformat)
  13.         xlBook.Close()
  14.         xlBook.Saved = True
  15.         xlApp.Quit()
  16.  
  17.         Dim myDriver As New OleDb.OleDbConnection("Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=C:\Program Files\STOCK TAKE SYSTEM;Extensions=asc,csv,tab,txt;")
  18.         Dim myConnection As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\STOCK TAKE SYSTEM;Extended Properties=""text;HDR=Yes;FMT=Delimited""")
  19.         Dim insertData As New DataSet
  20.         Dim mydatatable As DataTable
  21.         Dim ds As DataSet
  22.         Dim sql As String
  23.  
  24.         connectDB = New connection("SAMPLE", "", "")
  25.         Dim myDataAdapter As New OleDb.OleDbDataAdapter("SELECT * FROM [STS.CSV]", myConnection)
  26.         ' ds = connectdb.updateRecord("insert into Sample.SRST_TEST ("
  27.  
  28.         Try
  29.             myDataAdapter.Fill(insertData)
  30.             DataGrid1.DataSource = insertData
  31.  
  32.         Catch Ex As Exception
  33.             MessageBox.Show(Ex.Message)
  34.         End Try
  35.         'closes connection upon complete
  36.         myConnection.Close()    
  37.  
  38.     End Sub

I'm suppose to make an application, non web based

Thanks in advance