473,411 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

How To Cancel Edits on a control?

Using Visual Basic 2005 how do I cancel edits on a databound control. I
want the user to be able to cancel all edits on a form. My main
databound control is a DataGridView which is bound to a BindingSource,
which in turn is bound to a SQL Server data source. I tried
ResetBindings, but nothing appears to happen visually, and the
bindingsource's HasChanges method indicates that changes have been made
even after I attempt to use it.

Thanks,
Crazy

Mar 15 '06 #1
3 1070
Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuExit.Click
Dim changes As DataSet = DsProduct1.GetChanges()
Dim answer As DialogResult
If Not changes Is Nothing Then
answer = MessageBox.Show("Save data changes?", "Save",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
If answer = DialogResult.Yes Then
Dim count As Integer = dbProduct.Update(changes)
MessageBox.Show("Database updated " & count & " rows
successfully")
DsProduct1.AcceptChanges()
End If
End If
Me.Close()
End Sub

Mar 15 '06 #2
Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuExit.Click
Dim changes As DataSet = DsProduct1.GetChanges()
Dim answer As DialogResult
If Not changes Is Nothing Then
answer = MessageBox.Show("Save data changes?", "Save",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
If answer = DialogResult.Yes Then
Dim count As Integer = dbProduct.Update(changes)
MessageBox.Show("Database updated " & count & " rows
successfully")
DsProduct1.AcceptChanges()
End If
End If
Me.Close()
End Sub

Mar 15 '06 #3

dp*****@gmail.com wrote:
Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuExit.Click
Dim changes As DataSet = DsProduct1.GetChanges()
Dim answer As DialogResult
If Not changes Is Nothing Then
answer = MessageBox.Show("Save data changes?", "Save",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
If answer = DialogResult.Yes Then
Dim count As Integer = dbProduct.Update(changes)
MessageBox.Show("Database updated " & count & " rows
successfully")
DsProduct1.AcceptChanges()
End If
End If
Me.Close()
End Sub


Thanks,

I actually ended up using RejectChanges which seems to work fine in
conjunction
with HasChanges.

Thanks again,

Mar 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Deano | last post by:
Alot of my forms are bound. I would like to offer a Cancel option so that they can make as many changes as they like and still Cancel out without making any changes. I have one idea of how to...
14
by: clintonG | last post by:
This is an appeal for peer support sent to Microsoft as will be noted in closing. The Login control does not include a Cancel button. The only option is to convert the Login control to a...
4
by: martin | last post by:
Hello, Is there a way to make a kind of "cancel" button on a form? Suppose you accidently changed or overwrote some data in a form, then I'd like to leave this form at once and cancel any...
0
by: coolx | last post by:
Hi. I am trying to make a client and a server. Server must be work always and sometimes I open and close the client program. When client is opened, I want to show a message on server side "client...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.