Newbie question about ADO.Net

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

Hello all -

I'm still getting acclimated every day with understanding
ADO.Net and the disconnected ideology more and more and I
have run into an issue that I was hoping this easy
question could be answered.

Based on inserts and updates that take place in 1 form, I
want to update a counter on another open form. Yet, when
I .close the second form I made the changes to, what event
gets called in the first form where I can trigger my
process to do the update? I tried the GotFocus but that
isn't right and I don't want to create a new instance of
the form because of data a user may have typed in already.

This may seem easy to all of you so I appreciate your
assistance.

Thanks,
MR
 
If you use frm2.Show from frm1 and then make changes to frm2 (or the data
it's exposing), then close frm2, no event is getting fired in frm1. frm2's
Closing event OnClose will be fired. You could create a single instance
class or module that neither form owns but both can reference and use a
field in it to keep track of your counter. You could make the property of
the class fire an event each time it's incremented....counterChanged and
from the Set property, each time it's set, Raise counterChanged. You can
have an event handler anywhere in your app or in multiple places that
watches counterChanged and when it's raised, do something(whatever you are
trying to accomplish with GotFocus). From the sounds of it though, if I'm
understanding you correctly, this is a class issue more than an ADO.NET one.
I'm guessing that what I suggested may be a bit much if you are new to
Events, and I may have misundertsood what you are trying to accomplish. If
so, let me know and I'll write out an example. BTW, can you let me know a
little more about what you are trying to do? What is going on in the
update? If it's simply to use the data from frm2 that was changed, you can
call update from there. Also, you can declare your dataset in a static
class or in a module, and both forms can reference it. You could fire
update for either or both and probably accomplish what you want. If you are
updating data on form2 but firing Update from form1, I think you could get
into some trouble....when form2 closes, you should probably fire your
updates. If you don't, you'll have to set a Dirty variable that form1 can
see and remind the user that they need to fire the update before closing
form1. Either way, let me know if I can help.

Bill
 
I apppreciate your response.

All I'm attempting to do is in frm2, add a few records to
a table. Once I exit, I want frm1's counter field, which
is updated in the RefreshCounters function that I've
created. I just want to have a simply carry over or
process that I can access. Nothing extravagant because I
think it'll be overkill.

Any suggestions aside from ones notes in the previous
thread are appreciated as well.

Mike
-----Original Message-----
If you use frm2.Show from frm1 and then make changes to frm2 (or the data
it's exposing), then close frm2, no event is getting fired in frm1. frm2's
Closing event OnClose will be fired. You could create a single instance
class or module that neither form owns but both can reference and use a
field in it to keep track of your counter. You could make the property of
the class fire an event each time it's
incremented....counterChanged and
 
Back
Top