Check if newly added records have been saved
Check if newly added records have been saved
Check if newly added records have been saved
Check if newly added records have been saved
Check if newly added records have been saved
Check if newly added records have been saved Check if newly added records have been saved Check if newly added records have been saved Check if newly added records have been saved Check if newly added records have been saved Check if newly added records have been saved Check if newly added records have been saved Check if newly added records have been saved
Check if newly added records have been saved Check if newly added records have been saved
Check if newly added records have been saved
Go Back  Xtreme Visual Basic Talk > > > Check if newly added records have been saved


Reply
 
Thread Tools Display Modes
  #1  
Old 05-07-2008, 09:14 PM
147 147 is offline
Newcomer
 
Join Date: May 2008
Location: Eastern Shore
Posts: 20
Default Check if newly added records have been saved


I'm trying to build a new customer data entry page for a db project. One of the features I would like to add is a way to check and see if there have been any new records that have been added that haven't been explicitly saved to the db. If so, when the form_closing events fires I want to evaluate whether or not new entries have been made that weren't saved, and then count the number of rows that haven't been saved.

I've already written the code to any a positive result. A message box with Yes/No/Cancel options will appear to give the option to save the data (Yes), lose the changes (No) or go back and continue working (Cancel). It all looks great- I just don't know how to make it activate.

I searched through MSDN forums, the MSDN documentation and performed a breif search of the topics on this board, but I'm not seeing anything specific. I'm sure if this can be done someone else has already done it, but since I don't know what terminology to use in my search I'm not having any luck finding it.

I'm doing this because I want to make it possible for someone to stop what they're doing and intentionally lose all of the information they've been entering without explicitly deleting every record they input. Granted, this seems like an unlikely scenario but I could envision it being useful.

I'm sure there's a simple way to make this happen, but I'm still kindof stumbling around in the dark when it comes to ADO material. I've been poking around at the tableadapters and bindingsources in the form but I can't seem to find the right...function, I guess.

Thanks for any help in advance!

Last edited by 147; 05-08-2008 at 08:41 AM.
Reply With Quote
  #2  
Old 05-08-2008, 08:48 AM
MKoslof's Avatar
MKoslofCheck if newly added records have been saved MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

1) Use a stored procedure that returns the SCOPE_IDENTITY() of the record just inserted, if the return of the output parameter is greater than 0, a new record was added

2) To check if a record already exists, you can use an IF EXISTS query in your insert proc. If the record already exists (you would build your where logic, WHERE F1 = X And F2 = Y, depends on what makes it unique) you can use the RAISEERROR feature of SQL Server and catch that at the UI tier, if that is returned you show the user a message box saying "This record already exists, etc). If it doesn't, you know you got back the Scope_Identity and its been inserted
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Check if newly added records have been saved
Check if newly added records have been saved
Check if newly added records have been saved Check if newly added records have been saved
Check if newly added records have been saved
Check if newly added records have been saved
Check if newly added records have been saved Check if newly added records have been saved Check if newly added records have been saved Check if newly added records have been saved Check if newly added records have been saved Check if newly added records have been saved Check if newly added records have been saved
Check if newly added records have been saved
Check if newly added records have been saved
 
Check if newly added records have been saved
Check if newly added records have been saved
 
-->