"Mr. Arnold" <MR.
Ar****@Arnold.c omskrev i meddelelsen
news:ex******** ******@TK2MSFTN GP03.phx.gbl...
>
"Finn Stampe Mikkelsen" <st****@city.dk wrote in message
news:Os******** ******@TK2MSFTN GP05.phx.gbl...
>Hi
I have defined a table in my database, with 2 date-fields. I have set a
default value to DBNull. I have integrated a nullable datetimepicker
control to my project and set the apropriate NullValue in my
datagridview.. .
Everything works great, with a table-row added manually to the database,
without setting any value to the second date-field. Both the datagridview
and the datetimepicker displays correctly the DBNull value..
My problem however is, how do i add a new row in my program, setting one
date to an actual date, but leaving the other un-set and thereby leaving
it to the DBNull i have setup in the table-design??
Well, I would suspect that you wouldn't address the field in question and
not put anything in the field, which the database itself would insert the
record with Null data in the record field.
You may have to go to the database itself for the table's field and set
the field to use Null data as the default value when the record is
inserted into the table.
Hi
I have been to the table-design and set the default value to be Null. I
can't seem to find any way to pass the null value to the DB.
The field is a Date field. I can't pass DBNull.value, i have tried VB's
Nothing reference but it passes a value leaving the datefield set to dec.
30., 1899... i can't pass "" and i can't ommit the field in the addrow
method...
So i can't seem to find a way that i can do that...
Here's my code
Kunder.Arbejdso pgaver.AddArbej dsopgaverRow(Ar bejdsNummerText Box.Text,
StolTypeTextBox .Text, _ Kunder._Kunder. Rows(KunderBind ingSource.Posit ion) ,
DatoStartDateTi mePicker.Value, DatoSlutDateTim ePicker.Value)
It's the last field (DatoSlutDateTi mePicker.Value) i need to pass to the DB
as a null value, since it depick's a date marking the end of a project. This
date is not set, when creating a project and logically should be set to
null..
I have worked around the DBNull problem with DateTimePicker and created a
control handling this and my column in my DataGridView is setup to show the
NullValue with the correct text..
Now i can't seem to create the project by adding a new row, passing this
DBNull value in the field...
/Finn