geedub1961
asked on
vb.net dataset question
I am a novice with vb.net - I have used access alot but very little experience in vb.net.
I built a simple form that has two fields and is connected via dataset.
I need help understanding how to update from the dataset back to the table from where it came from.
THIS IS THE CODE
Public Class Form1
Private Sub CustomersBindingNavigatorS aveItem_Cl ick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomersBindingNavigatorS aveItem.Cl ick
Me.Validate()
Me.CustomersBindingSource. EndEdit()
Me.TableAdapterManager.Upd ateAll(Me. NwindDataS et)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'NwindDataSet.Customers' table. You can move, or remove it, as needed.
Me.CustomersTableAdapter.F ill(Me.Nwi ndDataSet. Customers)
End Sub
Private Sub BindingNavigatorAddNewItem _Click(ByV al sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem .Click
End Sub
End Class
I built a simple form that has two fields and is connected via dataset.
I need help understanding how to update from the dataset back to the table from where it came from.
THIS IS THE CODE
Public Class Form1
Private Sub CustomersBindingNavigatorS
Me.Validate()
Me.CustomersBindingSource.
Me.TableAdapterManager.Upd
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'NwindDataSet.Customers' table. You can move, or remove it, as needed.
Me.CustomersTableAdapter.F
End Sub
Private Sub BindingNavigatorAddNewItem
End Sub
End Class
Hi!
check your code by doing it this way:
http://forums.asp.net/p/1390628/2978412.aspx
Also, check it by using AcceptChanges() method of DataSet.
check your code by doing it this way:
http://forums.asp.net/p/1390628/2978412.aspx
Also, check it by using AcceptChanges() method of DataSet.
Since you need Vb.Net code so use this converter:
http://www.developerfusion.com/tools/convert/csharp-to-vb/
http://www.developerfusion.com/tools/convert/csharp-to-vb/
Still around?
ASKER
Yes - I finally figured this out - at least to update the database. For anyone else trying this it might be important to note that I needed to build the application before the update would actually work.
I am not able to add a record and have it saved yet. Maybe I can get some help on that part.
Whenever I add a record i get "failed to update".
gw
Try
Me.Validate()
Me.CustomersBindingSource. EndEdit()
Me.CustomersTableAdapter.U pdate(Me.N windDataSe t1.Custome rs)
MsgBox("Update successful")
Catch ex As Exception
MsgBox("Update failed")
End Try
I am not able to add a record and have it saved yet. Maybe I can get some help on that part.
Whenever I add a record i get "failed to update".
gw
Try
Me.Validate()
Me.CustomersBindingSource.
Me.CustomersTableAdapter.U
MsgBox("Update successful")
Catch ex As Exception
MsgBox("Update failed")
End Try
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Db2DataSet.tblStd.AcceptCh
What is the tblstd in the middle? is that the same as my CustomersTableAdapter?
gw
ASKER
Ok - I got it is the table "customers" in my case
ASKER
Thanks Shahan
ASKER
thanks
ASKER
Thanks for any help on this.