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….
[FONT="] [/FONT]
Any ideas why this is not saving?
Thanks guys
Nick
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.NET:
[FONT="] [/FONT]
[FONT="] [COLOR=blue]Private[/COLOR] [COLOR=blue]Sub[/COLOR] bindingNavigatorSaveItem_Click([COLOR=blue]ByVal[/COLOR] sender [COLOR=blue]As[/COLOR] System.Object, [COLOR=blue]ByVal[/COLOR] e [COLOR=blue]As[/COLOR] System.EventArgs) [COLOR=blue]Handles[/COLOR] bindingNavigatorSaveItem.Click[/FONT]
[FONT="] [COLOR=blue]If[/COLOR] [COLOR=blue]Me[/COLOR].Validate [COLOR=blue]Then[/COLOR][/FONT]
[FONT="] [COLOR=blue]Me[/COLOR].StockBindingSource.EndEdit()[/FONT]
[FONT="] [COLOR=blue]Me[/COLOR].StockTableAdapter.Update([COLOR=blue]Me[/COLOR].StockDataSet.Stock)[/FONT]
[FONT="] [COLOR=blue]Else[/COLOR][/FONT]
[FONT="] System.Windows.Forms.MessageBox.Show([COLOR=blue]Me[/COLOR], [COLOR=maroon]"Validation errors occurred."[/COLOR], [COLOR=maroon]"Save"[/COLOR], System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning)[/FONT]
[FONT="] [COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR][/FONT]
[FONT="] [COLOR=blue]End[/COLOR] [COLOR=blue]Sub[/COLOR][/FONT]
[COLOR=blue][FONT="] [/FONT][/COLOR]
[COLOR=blue][FONT="]Private[/FONT][/COLOR][FONT="] [COLOR=blue]Sub[/COLOR] ImportBtn_Click([COLOR=blue]ByVal[/COLOR] sender [COLOR=blue]As[/COLOR] [COLOR=blue]Object[/COLOR], [COLOR=blue]ByVal[/COLOR] e [COLOR=blue]As[/COLOR] System.EventArgs) [COLOR=blue]Handles[/COLOR] ImportBtn.Click[/FONT]
[FONT="] [COLOR=blue]Dim[/COLOR] DS [COLOR=blue]As[/COLOR] System.Data.DataSet[/FONT]
[FONT="] [COLOR=blue]Dim[/COLOR] MyAdapter [COLOR=blue]As[/COLOR] System.Data.OleDb.OleDbDataAdapter[/FONT]
[FONT="] [COLOR=blue]Dim[/COLOR] MyConnection [COLOR=blue]As[/COLOR] System.Data.OleDb.OleDbConnection[/FONT]
[FONT="] MyConnection = [COLOR=blue]New[/COLOR] System.Data.OleDb.OleDbConnection( _[/FONT]
[FONT="] [COLOR=maroon]"provider=Microsoft.Jet.OLEDB.4.0; "[/COLOR] & _[/FONT]
[FONT="] [COLOR=maroon]"data source=D:\Stock.XLS; "[/COLOR] & _[/FONT]
[FONT="] [COLOR=maroon]"Extended Properties=Excel 8.0;"[/COLOR])[COLOR=green][/COLOR][/FONT]
[FONT="] MyAdapter = [COLOR=blue]New[/COLOR] System.Data.OleDb.OleDbDataAdapter( _[/FONT]
[FONT="] [COLOR=maroon]"select * from [Sheet1$]"[/COLOR], MyConnection)[/FONT]
[FONT="] DS = [COLOR=blue]New[/COLOR] System.Data.DataSet()[/FONT]
[FONT="] MyAdapter.Fill(DS, [COLOR=maroon]"StockDataGridView"[/COLOR])[/FONT]
[FONT="] MyConnection.Close()[/FONT]
[FONT="] StockDataGridView.DataSource = DS.Tables([COLOR=maroon]"StockDataGridView"[/COLOR])[/FONT]
[FONT="] [/FONT]
Any ideas why this is not saving?
Thanks guys
Nick