12 Replies - 362 Views - Last Post: 10 May 2013 - 01:29 PM Rate Topic: -----

#1 frankwright1  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 93
  • Joined: 07-May 12

tabs and update stored procedure

Posted 09 May 2013 - 01:22 PM

Hi - this one is really weird. Im sure Im missing something very obvious.

I have an windows form application with five tabs.

When I save, the update stored procedure runs ok

If I re-run the application, but havent gone into one of the tabs, then click save, the data is lost.

Any help?

Thanks
Frank
Is This A Good Question/Topic? 0
  • +

Replies To: tabs and update stored procedure

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9277
  • View blog
  • Posts: 34,780
  • Joined: 12-June 08

Re: tabs and update stored procedure

Posted 09 May 2013 - 01:24 PM

If you are over writing your saves you would be best to slap a breakpoint on your 'save' method.. and see where it is called and how to prevent that from happening.
Was This Post Helpful? 0
  • +
  • -

#3 frankwright1  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 93
  • Joined: 07-May 12

Re: tabs and update stored procedure

Posted 09 May 2013 - 01:34 PM

Im pretty sure Im not over-riding saves. Is just if a textbox is on a hidden tab that hasn't been shown, its being saved as NULL
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9277
  • View blog
  • Posts: 34,780
  • Joined: 12-June 08

Re: tabs and update stored procedure

Posted 09 May 2013 - 01:36 PM

Let's step back - what do you expect the appropriate action from the app would be? If you are saving a,b,c,x,y,z and you do not have y or z filled out.. what is your expectation? To retain the x and y from the last save?>
Was This Post Helpful? 0
  • +
  • -

#5 frankwright1  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 93
  • Joined: 07-May 12

Re: tabs and update stored procedure

Posted 09 May 2013 - 01:40 PM

Yes, that is my expectation. I dont understand why the database table is cleared when the application is closed.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9277
  • View blog
  • Posts: 34,780
  • Joined: 12-June 08

Re: tabs and update stored procedure

Posted 09 May 2013 - 01:44 PM

In my last post - you would need to program it. If you are writing nulls - and not telling it not to - then yeah.. of course it will follow what you told it.

Quote

dont understand why the database table is cleared when the application is closed.

Ah, what? Explain.
Was This Post Helpful? 0
  • +
  • -

#7 frankwright1  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 93
  • Joined: 07-May 12

Re: tabs and update stored procedure

Posted 09 May 2013 - 01:58 PM

Ok - here's what happens... I hope this explains it..sorry if I seem over simplistic, its for me to make sure I'm clear (I really appreciate your help on this)

1. I have an application with a tab control
2. I have a binding navigator with a save button set to run an update stored procedure
3. Tab 1 is the tab that opens when I run the app. It has address fields.
4. Tab 3 is the tab for invoices etc.
5. Both the textboxes in tab 1 and tab 3 update columns in the same table.
6. If I debug the app and make a change to a textbox in tab1 and hit save, it saves ok
7. If I debug the app and select tab 3 and make a change to a textbox here and hit save it saves ok
8. If I debug the app and ***dont select tab 3*** and hit save it appears to save ok......but..............
9. Next time I debug and hit tab3, the textbox is empty
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9277
  • View blog
  • Posts: 34,780
  • Joined: 12-June 08

Re: tabs and update stored procedure

Posted 09 May 2013 - 02:04 PM

Okay.. if I am following right you want different things to save when you have specific tabs up? As in if you only have tab 1 up and click save it shouldn't fire save off for tab 3, or tab 20?
Was This Post Helpful? 0
  • +
  • -

#9 frankwright1  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 93
  • Joined: 07-May 12

Re: tabs and update stored procedure

Posted 09 May 2013 - 02:09 PM

No, the same save click should save textboxes on all tabs
Was This Post Helpful? 0
  • +
  • -

#10 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9277
  • View blog
  • Posts: 34,780
  • Joined: 12-June 08

Re: tabs and update stored procedure

Posted 09 May 2013 - 02:13 PM

Okay so it is working as designed. If you haven't reached a tab and click save - writing null across all the values seems.. appropriate.

Now.. on the other hand... if you don't want this to happen then you need to either:
a. do some validation before the save making sure all the critical textboxes are filled.
b. dynamically change your sql update statement based on what is null so you are not over writing anything.
Was This Post Helpful? 1
  • +
  • -

#11 frankwright1  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 93
  • Joined: 07-May 12

Re: tabs and update stored procedure

Posted 09 May 2013 - 02:22 PM

Thanks - Ive not yet solved it, but this has given me something to think about. Im going to try a few things, may need some more help though.
Was This Post Helpful? 0
  • +
  • -

#12 frankwright1  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 93
  • Joined: 07-May 12

Re: tabs and update stored procedure

Posted 10 May 2013 - 01:17 PM

Ok - heres what Im going to do. Ill split the stored procedure so I only save whats on each tab. 5 stored procedures for five tabs. They will be set to run when I leave each tab. Im not sure what to do about going in and changing just one tab without leaving it though.

Unless is there someway I can identify which tab Im in and send that as a string into the title of the stored procedure I want to run?

Thanks
Frank
Was This Post Helpful? 0
  • +
  • -

#13 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9277
  • View blog
  • Posts: 34,780
  • Joined: 12-June 08

Re: tabs and update stored procedure

Posted 10 May 2013 - 01:29 PM

I see you haven't been looking through the MSDN docs or intellisense! ;)

'Selected tab' tends to do the trick.
http://msdn.microsof...tabcontrol.aspx
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1