Hi guys
I have this program that imports and Excel spreadsheet to a database, but when I try and save the imported information, nothing is saved.
Here is my code I have so far….
VB Code:
Private Sub bindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bindingNavigatorSaveItem.Click If Me.Validate Then Me.StockBindingSource.EndEdit() Me.StockTableAdapter.Update(Me.StockDataSet.Stock) Else System.Windows.Forms.MessageBox.Show(Me, "Validation errors occurred.", "Save", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning) End If End Sub Private Sub ImportBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ImportBtn.Click Dim DS As System.Data.DataSet Dim MyAdapter As System.Data.OleDb.OleDbDataAdapter Dim MyConnection As System.Data.OleDb.OleDbConnection MyConnection = New System.Data.OleDb.OleDbConnection( _ "provider=Microsoft.Jet.OLEDB.4.0; " & _ "data source=D:\Stock.XLS; " & _ "Extended Properties=Excel 8.0;") ' Select the data from Sheet1 of the workbook. MyAdapter = New System.Data.OleDb.OleDbDataAdapter( _ "select * from [Sheet1$]", MyConnection) DS = New System.Data.DataSet() MyAdapter.Fill(DS, "StockDataGridView") MyConnection.Close() StockDataGridView.DataSource = DS.Tables("StockDataGridView") 'Tablegrid Name End Sub
Any ideas why this is not saving?
Thanks guys
Nick




Reply With Quote