Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 25th, 2007, 12:12 AM
Kia Kia is offline
Authorized User
 
Join Date: Jun 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Check if dataset was modified before closing form

Hi,

This has to be simple. I have a windows form in vb.net opening tables in TableAdapters and DataAdapters.

I have 2 questions..

1. How can I check just before closing the form if any database information was modified? I want to give a save option if any mods were performed.

2. I have to open a DataAdapter so that I can use transactions and record locking. But I've only been able to pass the SQL in code into the SQLCommand. How do I retrieve the SQL from my dataset or use the Datasets in my project so that I don't have to hard code SQL in my code?

Thanks
Kia
 
Old June 29th, 2007, 06:27 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

hey kia,

1) use DataSet.HasChanges function to check whether it has been modified or not.

2) i m not able to understand wht u wanna ask...


bye,
ashu


 
Old July 1st, 2007, 07:37 AM
Kia Kia is offline
Authorized User
 
Join Date: Jun 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Ashu, thanks for your replies.

1. Thanks that's exactly what I needed.

2. I just re-read my own post and you're right.. It makes no sense! I'm having a little trouble explaining this problem, but here goes!

I want to do is setup a DataSet with the tables and selects, updates etc, as if I was going to use it in my form with TableAdapters. But...

In the form I have to use DataAdapters in order to make use of transactions. So, I wonder if its possible to hook up the DataAdapter to the SQL from a TableAdapter within a Dataset that is not on the form?
 
Old July 2nd, 2007, 12:26 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

hey kia,

u can use a Global DataSet variable and use it in any form u require
u can see the following links regarding TableAdapter:

http://msdn2.microsoft.com/en-us/library/bz9tthwx(VS.80).aspx

http://msdn2.microsoft.com/en-us/library/kda44dwy(VS.80).aspx



 
Old July 16th, 2007, 08:46 PM
Kia Kia is offline
Authorized User
 
Join Date: Jun 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks again mate.. Got me out of the hole again.

Back to issue 1: Using HasChanges to see if there are changes to the BS..

I found that I first have to run "EndEdit" before "HasChanges" gets updated.

Problem is that there are required fields in the table, so if the user wants to leave the form without saving(say they click "new" and immediately close the form), they will be faced with the error from each required field before HasChanges is set and they get to the "Do you want to save" option.

Any ideas how to get around this? Currently I'm using a global variable that's set manually. Is there a way to detect changes without first executing EndEdit?





Similar Threads
Thread Thread Starter Forum Replies Last Post
closing a form mnvijay VS.NET 2002/2003 4 December 18th, 2007 07:20 AM
How to refresh owner form on closing of child form akumarp2p C# 2005 0 December 22nd, 2006 10:27 AM
Form & Subform Closing w/Completion Check SarahL Access 4 June 2nd, 2006 07:22 AM
Closing a form after opening another form rosebushr Access 2 January 7th, 2006 04:34 AM
Chapter 16 - DataSet Example - MODIFIED??? cliffd64 VB.NET 2002/2003 Basics 2 May 17th, 2005 12:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.