Hi guys. I need help in updating Excel files through Datagrid. I can update it through a fixed update sql statement(Update table_name Set field1=value1, field2=value2 Where ID=unique_no) but I encountered a situation where a spreadsheet can have 3 columns, sometimes 5 and so on. My point is can I update the excel file without the restriction of columns based on Set. I know Set is inseperable in the Update Command so I tried the Interop way but my application stopped working, it doesn't show any error. Here's what I have so far:
xlWorkBook = xlApp.Workbooks.Open(path)
xlWorkSheet = xlWorkBook.Worksheets(3)
Dim w = 0
Dim r = w + 3
Dim x = DataGridView1.RowCount - 1
Do
Dim y = 1
Dim c = y + 1
Dim z = DataGridView1.ColumnCount
Do
xlWorkSheet.Cells(r, c) = DataGridView1.Rows(w).Cells(y).Value
Loop While (y < z)
w = w + 1
Loop While (w < x)
xlWorkBook.Save()
xlWorkBook.Close()