473,847 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

determine after using addnew

is there a way to know if the form is edited or not after calling
addnew? Me.BindingConte xt(DsStudentCou rse1, "Students").Add New()

because i got an error after closing the form. because in my form
closing event i have a code to call the EndCurrentEdit to determine if
the dataset has changes or not. here is my code in closing event

Private Sub Students_Closin g(ByVal sender As Object, ByVal e
As System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit()
Try
If DsStudentCourse 1.HasChanges Then
If MessageBox.Show ("There are unsave changes in
the Form, Yes to Save, No to Discard and exit?", "Save changes",
MessageBoxButto ns.YesNo, MessageBoxIcon. Question) = DialogResult.Ye s
Then
Save_Record()
Else
Me.BindingConte xt(DsStudentCou rse1,
"Students").Can celCurrentEdit( )
End If
End If
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub

the problem is in the Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit() line of code after calling addnew and
then closing the form without editing the form.

the error generated is "Column 'IDNo' does not allow nulls." because
IDNo is a primary key.

thanks in advance for any help.
Nov 20 '05 #1
3 1853
I don't know of a way to determine its state, but why not call cancel
current edit. you can tell if the dataset has changes or not by using
DataSet.HasChan ges(); which returns a bool. If it doesn't go ahead and
cancel the current edit (depending on how you want the app to behave this
should do it for you).
"jaYPee" <hi******@yahoo .com> wrote in message
news:vm******** *************** *********@4ax.c om...
is there a way to know if the form is edited or not after calling
addnew? Me.BindingConte xt(DsStudentCou rse1, "Students").Add New()

because i got an error after closing the form. because in my form
closing event i have a code to call the EndCurrentEdit to determine if
the dataset has changes or not. here is my code in closing event

Private Sub Students_Closin g(ByVal sender As Object, ByVal e
As System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit()
Try
If DsStudentCourse 1.HasChanges Then
If MessageBox.Show ("There are unsave changes in
the Form, Yes to Save, No to Discard and exit?", "Save changes",
MessageBoxButto ns.YesNo, MessageBoxIcon. Question) = DialogResult.Ye s
Then
Save_Record()
Else
Me.BindingConte xt(DsStudentCou rse1,
"Students").Can celCurrentEdit( )
End If
End If
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub

the problem is in the Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit() line of code after calling addnew and
then closing the form without editing the form.

the error generated is "Column 'IDNo' does not allow nulls." because
IDNo is a primary key.

thanks in advance for any help.

Nov 20 '05 #2
thanks for the reply. however DataSet.HasChan ges() is only applicable
when the control is datagrid. don't know if i'm wrong or not. but as i
have experience eventhough i edit the textbox in my form and close the
form and call DataSet.HasChan ges() is it returns false.
On Wed, 28 Apr 2004 00:28:47 -0400, "William Ryan eMVP"
<do********@com cast.nospam.net > wrote:
I don't know of a way to determine its state, but why not call cancel
current edit. you can tell if the dataset has changes or not by using
DataSet.HasCha nges(); which returns a bool. If it doesn't go ahead and
cancel the current edit (depending on how you want the app to behave this
should do it for you).
"jaYPee" <hi******@yahoo .com> wrote in message
news:vm******* *************** **********@4ax. com...
is there a way to know if the form is edited or not after calling
addnew? Me.BindingConte xt(DsStudentCou rse1, "Students").Add New()

because i got an error after closing the form. because in my form
closing event i have a code to call the EndCurrentEdit to determine if
the dataset has changes or not. here is my code in closing event

Private Sub Students_Closin g(ByVal sender As Object, ByVal e
As System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit()
Try
If DsStudentCourse 1.HasChanges Then
If MessageBox.Show ("There are unsave changes in
the Form, Yes to Save, No to Discard and exit?", "Save changes",
MessageBoxButto ns.YesNo, MessageBoxIcon. Question) = DialogResult.Ye s
Then
Save_Record()
Else
Me.BindingConte xt(DsStudentCou rse1,
"Students").Can celCurrentEdit( )
End If
End If
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub

the problem is in the Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit() line of code after calling addnew and
then closing the form without editing the form.

the error generated is "Column 'IDNo' does not allow nulls." because
IDNo is a primary key.

thanks in advance for any help.


Nov 20 '05 #3
Actually, that's not true. HasChanges has nothign to do with a
Datagrid...the datagrid is only incidental in that it's one mechanism to
edit the data. If HasChanges is false, your update isn't going to do
anything. TO prove it, trap the StateChanged event of your connection. Put
a messagebox in it. Then, right after dataadapter.fil l the very next line
(test HasChanges, it will be false). Next, create a loop to 1000 or 10000
or whatever suits you. Then, in the loop call daadapter.Updat e. You'll
notice that your messagebox never shows. That's because the connection
(which is closed at this point) doesn't open any more (while in the loop
calling Update) which proves it's not sending anything to the db. Next
line, Change a value of the datatable. call dataAdapter.Upd ate again, your
messagebox will show this time. It will show twice on fill, once when it
opens, once when it closes.

hasChanges is a property of the dataset not the grid.
jaYPee" <hi******@yahoo .com> wrote in message
news:f1******** *************** *********@4ax.c om...
thanks for the reply. however DataSet.HasChan ges() is only applicable
when the control is datagrid. don't know if i'm wrong or not. but as i
have experience eventhough i edit the textbox in my form and close the
form and call DataSet.HasChan ges() is it returns false.
On Wed, 28 Apr 2004 00:28:47 -0400, "William Ryan eMVP"
<do********@com cast.nospam.net > wrote:
I don't know of a way to determine its state, but why not call cancel
current edit. you can tell if the dataset has changes or not by using
DataSet.HasCha nges(); which returns a bool. If it doesn't go ahead and
cancel the current edit (depending on how you want the app to behave this
should do it for you).
"jaYPee" <hi******@yahoo .com> wrote in message
news:vm******* *************** **********@4ax. com...
is there a way to know if the form is edited or not after calling
addnew? Me.BindingConte xt(DsStudentCou rse1, "Students").Add New()

because i got an error after closing the form. because in my form
closing event i have a code to call the EndCurrentEdit to determine if
the dataset has changes or not. here is my code in closing event

Private Sub Students_Closin g(ByVal sender As Object, ByVal e
As System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit()
Try
If DsStudentCourse 1.HasChanges Then
If MessageBox.Show ("There are unsave changes in
the Form, Yes to Save, No to Discard and exit?", "Save changes",
MessageBoxButto ns.YesNo, MessageBoxIcon. Question) = DialogResult.Ye s
Then
Save_Record()
Else
Me.BindingConte xt(DsStudentCou rse1,
"Students").Can celCurrentEdit( )
End If
End If
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub

the problem is in the Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit() line of code after calling addnew and
then closing the form without editing the form.

the error generated is "Column 'IDNo' does not allow nulls." because
IDNo is a primary key.

thanks in advance for any help.

Nov 20 '05 #4

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

Similar topics

4
6461
by: Phillip J. Allen | last post by:
Hi all, I have a table with an “autonumber” primary key field that also acts as a foreign key in 2 other tables. I would like to programmatically add a new record to the first table and the other 2 child tables. The reason for doing this is to copy one complete record (parent and child table records) into a new record so the user can make a few modifications. So how do I determine what will be the next auto-generated number for my...
40
3012
by: Jeff | last post by:
I have a system on a network and want to determine if anyone is currently connected to the back-end files. An interesting twist is that I have noticed that some users can be connected (have the front end open at the first form) and even though this links to the back-end files, there are no ldb files created. This is so I know when it is safe to compact the back-end files without going round to make sure everyone is logged off. User...
2
1371
by: guy | last post by:
if i use Generics.AddNew how do I pass an object to the items constructor? I have a set of class all inheriting from a base class, all requiring one parameter on their constructor - the data passed to it will be the same independent of the class type so how do i pass it to AddNew?
2
3844
by: pillmill | last post by:
I replaced AddNew statments with INSERT INTO, but am unable to write to the same tables. Foreign keys violations are the main errors. Why are these occuring ? Before: set rs3= db.OpenRecordset("tblMat", dbOpenDynaset) rs3.AddNew rs3!Mat = Rs!Mat rs3.Update
6
2212
by: Robin Lawrie | last post by:
Hi, Looking for some help here! I'm adding records to a SQL 2000 DB using the objRS.AddNew and objRS.Update methods. What I'd like to do is determine the new primary key value of the added record.
8
2361
by: MLH | last post by:
Here's a snippet from A97 HELP on AddNew... The record that was current before you used AddNew remains current. If you want to make the new record current, you can set the Bookmark property to the bookmark identified by the LastModified property setting. My own experience is indicating that the newly added record becomes current during the AddNew processes and REMAINS current after .Update method runs. This seems true even though the...
10
12725
by: MLH | last post by:
Suppose, in a multi-user environment, you have append query SQL in a VBA procedure that looks like INSERT INTO MyTable... and the next line reads MyVar=DMax("","MyTable... You can never be certain that MyVar will be set to the key-field value that was created when the Append query ran. Now, there are other ways to do it - I know - that will ensure you 'nab' the correct record. But I was wondering
1
2471
by: teenagelcruise | last post by:
hi, i have a problem with my code which is i cannot update and addnew data into the database but i can delete the data.plz give me an idea.this is my code that i wrote. <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Order Record</title> <meta name="Microsoft Border" content="tlb, default"> </head>
0
1080
by: durga2005 | last post by:
Hi In my webgrid I have three columns namely “Type” and “Category” and “code” .But while inserting new record I will not enter “Code” Value since it is automatically generated. When I click the AddNew linkbutton,a new row should be created with two textboxes and one Save Button at the footer of the webgrid. I have created the AddNew link button at the footer Now if I click the link 2 textboxes and one save button should be created...
0
9882
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9727
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10982
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10706
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7880
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7053
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5719
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5909
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4116
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.