Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 January 3rd, 2008, 07:19 AM
Registered User
 
Join Date: Dec 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Validation on a date field.

Hi, i'm making an desktop application(no client,server) in vb.net that can insert, update and remove rows from a db. I have 3 classes:

I have a form with textboxes, that represents a name and a date. A form saves it's data into a rwPatient object.

A class rwPatient representing a row where you can set the name and the date of the patient.
and a class tblPatient that represents a table that can do sorts, addrow,removerow etc.

before I do an (insert, update) I store the textboxes values into the rwPatient object using the function getFormValues() as rwPatient.
wich loops throught the form textboxes and sets the rwPatient values to the .text property of the textbox.

I have some design problems handling empty textboxes.
Should I handle empty textboxes on the form? ie
if txtName = vbnullstring then
messagebox.show("Srry the name field can't be left empty")

Or should I make all the fields nullable(of type) inside the rwPatient class and then in the form if the textbox is empty insert nothing in rwPatient, wich will return a error message event.

I have to use nullable becaus Date cannot be nothing.

I think the second is better, because errorhandling is all into one class, and mayby later on it is allowed to have a null value for date for example.

What would you suggest.
 
Old January 3rd, 2008, 08:03 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

OneQuestion:
I prefer neither. I prefer to let the database do the majority of the work. I pack the database with default values and constraints and I don't allow NULL fields. If a field is NULL, then I don't write it, especially in the name field. I create a separate table just for the middle initial and if the field is used I turn the midlnamebit to on and write the middle initial and patient's primary key in the middleinitial table. Let your DB, do most of your "grunt" work. By the way, what type of DB is it?

Hope this helps.

========================
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.
 
Old January 3rd, 2008, 08:20 AM
Registered User
 
Join Date: Dec 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

srry It's Ms Access I think it just returns an error when you try to insert an empty required field, and i'm fine with not allowing any null values. But I don't get to my db because I have to store the form values in the rwPatient class first anyway. wich doesn't accept "" as date input.

 
Old January 6th, 2008, 01:30 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

OneQuestion:

My Suggestion is as follows:
   1: Since rwPatient is a class, then set your default values within the class;
   2: On the date field, set the default value to "Today Date" or "Now" function value;
   3: Change the Name field to Last Name and First Name;
   4: Do ALL field validations at time of Form entry;
   5: Set Patient SSN default to: "000-00-0000".
Where / When do you set the Patient Primary Key?

Hope this helps.




========================
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating a Date field based on another field arholly Access VBA 6 November 22nd, 2006 11:19 AM
Field Validation Thurston Access 5 November 14th, 2005 12:40 PM
Text Field Validation zaeem Pro VB Databases 1 May 27th, 2005 12:36 PM
Date Field from Parameter Field narooma.12 Crystal Reports 0 November 14th, 2004 08:51 PM
DTS Import ( Date string to Date field) gfowajuh SQL Server 2000 1 September 30th, 2003 06:28 AM





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