Hello,

I'm pulling dates from a dataset and then assigning that to a textbox.

These dates can be null, that is where my problem comes in at. I guess there
is no such thing as an "empty date", I'll have to deal with the nulls, but
I'm having trouble assigning them.

I'd prefer to do it in one line of code if at all possible, just because I'm
assigning like 80 fields out of the dataset, and would rather not have that
many if then else's out there.

Does anyone have a good way to take a null value from a dataset and assign
it to a string value?

Thanks,
--Michael

Re: Assign a string value a null date in one line? by William

William
Wed Jan 07 14:47:09 CST 2004

Michael, it's not necessarily a great way to do things, but depending on the
circumstances it's ok. You can ensure that no nulls come back by using the
IsNull function and assigning a default value of string.Empty of '' in SQL.

If you aren't using a Strongly Typed DataSet, you should be cool.
"Michael" <raterus@localhost> wrote in message
news:ueMkP0V1DHA.3196@TK2MSFTNGP11.phx.gbl...
> Hello,
>
> I'm pulling dates from a dataset and then assigning that to a textbox.
>
> These dates can be null, that is where my problem comes in at. I guess
there
> is no such thing as an "empty date", I'll have to deal with the nulls, but
> I'm having trouble assigning them.
>
> I'd prefer to do it in one line of code if at all possible, just because
I'm
> assigning like 80 fields out of the dataset, and would rather not have
that
> many if then else's out there.
>
> Does anyone have a good way to take a null value from a dataset and assign
> it to a string value?
>
> Thanks,
> --Michael
>
>



Re: Assign a string value a null date in one line? by Michael

Michael
Wed Jan 07 15:14:19 CST 2004

I looked at that too, but using isnull there results in the date being set
at '1/1/1900' in the datasource. Yet another thing to check for.. :) I am
using a typed dataset, maybe I should experiment with the NullValue
attribute in the definition file.

"William Ryan" <dotnetguru@comcast.nospam.net> wrote in message
news:uyE5u7V1DHA.3656@TK2MSFTNGP11.phx.gbl...
> Michael, it's not necessarily a great way to do things, but depending on
the
> circumstances it's ok. You can ensure that no nulls come back by using
the
> IsNull function and assigning a default value of string.Empty of '' in
SQL.
>
> If you aren't using a Strongly Typed DataSet, you should be cool.
> "Michael" <raterus@localhost> wrote in message
> news:ueMkP0V1DHA.3196@TK2MSFTNGP11.phx.gbl...
> > Hello,
> >
> > I'm pulling dates from a dataset and then assigning that to a textbox.
> >
> > These dates can be null, that is where my problem comes in at. I guess
> there
> > is no such thing as an "empty date", I'll have to deal with the nulls,
but
> > I'm having trouble assigning them.
> >
> > I'd prefer to do it in one line of code if at all possible, just because
> I'm
> > assigning like 80 fields out of the dataset, and would rather not have
> that
> > many if then else's out there.
> >
> > Does anyone have a good way to take a null value from a dataset and
assign
> > it to a string value?
> >
> > Thanks,
> > --Michael
> >
> >
>
>



Re: Assign a string value a null date in one line? by Michael

Michael
Wed Jan 07 15:36:15 CST 2004

Hey this worked (all in one line), I didn't realize you could do this kind
of construct in VB.net


If ds.datatable(0).IsmydatefieldnameNull Then mystring = String.Empty Else
mystring = ds.datatable(0).mydatefieldname

"Michael" <raterus@localhost> wrote in message
news:ueMkP0V1DHA.3196@TK2MSFTNGP11.phx.gbl...
> Hello,
>
> I'm pulling dates from a dataset and then assigning that to a textbox.
>
> These dates can be null, that is where my problem comes in at. I guess
there
> is no such thing as an "empty date", I'll have to deal with the nulls, but
> I'm having trouble assigning them.
>
> I'd prefer to do it in one line of code if at all possible, just because
I'm
> assigning like 80 fields out of the dataset, and would rather not have
that
> many if then else's out there.
>
> Does anyone have a good way to take a null value from a dataset and assign
> it to a string value?
>
> Thanks,
> --Michael
>
>