Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2008

Tip: Looking for answers? Try searching our database.

passing back null to a database field if textbox is blank

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wishing I was skiing mom - 23 Jan 2008 01:54 GMT
I have a text box that represents Hours worked, I also have a text box that
represents Adjusted Hours worked.  If user wants to override the Hours worked
they enter a value in the Adjusted Hours worked text box.  In doing so the
Adjusted hours worked field in the database would then be updated to the
value entered, but in the event the user doesn't enter an adjusted hours
figure the database field should contain Null.  How do I pass the value null
from the adjusted hours worked text box, since it would be blank(empty, =
nothing, or whatever) to the database field?

Any help would be greatly appreciated, thanks in advance.
Jackie
RobinS - 24 Jan 2008 06:35 GMT
Is the textbox databound? If so, you can capture the Format and Parse
events. In the Format event, check the db value for null and display
string.Empty; in the Parse event, check the value in the textbox for
string.Empty and set it to DBNull.

If it's not data bound, can't you just handle it when you unload your
textbox into the dataset?

RobinS.
-----------------------------------
>I have a text box that represents Hours worked, I also have a text box that
> represents Adjusted Hours worked.  If user wants to override the Hours
[quoted text clipped - 9 lines]
> Any help would be greatly appreciated, thanks in advance.
> Jackie
Wishing I was skiing mom - 25 Jan 2008 16:53 GMT
The textbox is not databound and I ended up updating the db field only if the
user entered a numeric value otherwise db field was unchanged, as the db
field default is null.  This required additional code and additional update
processes that I was hoping I could avoid. I am thinking there must be a
better way, but need to move on from this.
Thanks,
Jackie

> Is the textbox databound? If so, you can capture the Format and Parse
> events. In the Format event, check the db value for null and display
[quoted text clipped - 19 lines]
> > Any help would be greatly appreciated, thanks in advance.
> > Jackie

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.