Hi,
I'm trying to save data from Dataset to mdb file. If I use BindingNavigator for inserting row, saving in mdb,.. everything works perfect (this is the autogenerated form which is made only with drag and drop).
Until now I programaticaly managed to insert vales into new row (cells) but I can't update mdb file - TableAdapter sucessfully.
Code:
Dim novaUsageVrsta As DataRow = Ds.Tables("tbl_usage").NewRow()
'here I'm adding rows
novaUsageVrsta(1) = Now.ToString("d")
novaUsageVrsta(2) = CurrentActiveWindow.Zacetek
novaUsageVrsta(3) = CurrentActiveWindow.Konec
'novaUsageVrsta(4) = CurrentActiveWindow.Trajanje
novaUsageVrsta(5) = UCase(CurrentActiveWindow.Proces)
novaUsageVrsta(6) = Environment.UserName
'Here could be a problem
Ds.tbl_usage.Rows.Add(novaUsageVrsta)
Ds.tbl_usage.AcceptChanges()
Me.Validate()
Me.Tbl_usageBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Ds)
And here is autogenerated code which works perfectly
How does BindingNavigator:
Private Sub Tbl_usageBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tbl_usageBindingNavigatorSaveItem.Click
Me.Validate()
Me.Tbl_usageBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Ds)
End Sub
So my problem is only that that I don't know how to isert new rows with values.
Thanks for help!
I'm trying to save data from Dataset to mdb file. If I use BindingNavigator for inserting row, saving in mdb,.. everything works perfect (this is the autogenerated form which is made only with drag and drop).
Until now I programaticaly managed to insert vales into new row (cells) but I can't update mdb file - TableAdapter sucessfully.
Code:
Dim novaUsageVrsta As DataRow = Ds.Tables("tbl_usage").NewRow()
'here I'm adding rows
novaUsageVrsta(1) = Now.ToString("d")
novaUsageVrsta(2) = CurrentActiveWindow.Zacetek
novaUsageVrsta(3) = CurrentActiveWindow.Konec
'novaUsageVrsta(4) = CurrentActiveWindow.Trajanje
novaUsageVrsta(5) = UCase(CurrentActiveWindow.Proces)
novaUsageVrsta(6) = Environment.UserName
'Here could be a problem
Ds.tbl_usage.Rows.Add(novaUsageVrsta)
Ds.tbl_usage.AcceptChanges()
Me.Validate()
Me.Tbl_usageBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Ds)
And here is autogenerated code which works perfectly
How does BindingNavigator:
Private Sub Tbl_usageBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tbl_usageBindingNavigatorSaveItem.Click
Me.Validate()
Me.Tbl_usageBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Ds)
End Sub
So my problem is only that that I don't know how to isert new rows with values.
Thanks for help!