Hey guys,
Thanks guys for the suggestions. I figured it out. It turns out that if you
have a checkbox in the form it causes a problem. Checkboxes don't handle
nulls too well. I had to put the following code in the form constructor to
make a default for the checkbox so when it comes time to select the record
there is a value that the checkbox can expect from the dataset.
InitializeComponent();
objdsEmployeeRecord.Tables["employee"].Columns["employee_hidden"].DefaultVal
ue = false;
Basically we are modifying the dataset before the checkbox has a chance to
see that it is null. If anyone has a problem with checkboxes with nulls or
any other fields that don't allow you to see the records its probably due to
nulls not being accepted by the component.
I also had a problem with datetime (getdate()) database defaults not showing
up as soon as I create records in the database. This problem drove me crazy
and I thought I'd add it to this post. Whats happening with the
oledbinsertcommand before the following modification is that a blank record
is being inserted for all fields. As you all know if blanks are inserted
then the defaults will not be inserted. So we have to force the default
values upon the insert of the form.
I had to edit the command text of the oledbinsertcommand to the following
(note the isnull has a getdate):
INSERT INTO employee
(employee_employeeaddress, employee_employeeapt,
employee_employeecity, employee_employeestate, employee_employeezip,
employee_employeehomephone,
employee_employeeworkphone, employee_employeedatehired,
employee_employeenotes, employee_hidden,
employee_employee_id_old, employee_employeefirstname,
employee_employeelastname, employee_employeeusername,
employee_employeestatus, employee_employeepassword,
employee_employeeovertimewage, employee_employeeregularwage,
employee_created_tm, employee_modified_tm,
employee_employeestatusdate, employee_employeedateterminated,
employee_employeesocialsecurity,
employee_employeemobilephone)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, isnull(?,
getdate()), isnull(?, getdate()), ?, ?, ?, ?);
Thanks,
Samer Abdullah
Just as a note for anyone