PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET DataRow Question

Reply

DataRow Question

 
Thread Tools Rate Thread
Old 02-01-2007, 03:09 PM   #1
Goofy
Guest
 
Posts: n/a
Default DataRow Question


Hi,

I have a row in a dataset table which is nullable ( and also on the sql
backend ), but how can I set it to a null.

if I try Myrow.myDate = nothing

when I test the row, I get "#12:00AM" why ??

?? IDEAS ??


--
Goofy


  Reply With Quote
Old 02-01-2007, 04:33 PM   #2
W.G. Ryan [MVP]
Guest
 
Posts: n/a
Default Re: DataRow Question

I believe the problem is that DateTime is a value type and therefore can't
be null. What value specifically do you want it to be? Do you need to
filter or do a IsDbNull.Value check?
"Goofy" <me@mine.com> wrote in message
news:ua5JRAoLHHA.2140@TK2MSFTNGP03.phx.gbl...
> Hi,
>
> I have a row in a dataset table which is nullable ( and also on the sql
> backend ), but how can I set it to a null.
>
> if I try Myrow.myDate = nothing
>
> when I test the row, I get "#12:00AM" why ??
>
> ?? IDEAS ??
>
>
> --
> Goofy
>



  Reply With Quote
Old 02-01-2007, 05:12 PM   #3
RobinS
Guest
 
Posts: n/a
Default Re: DataRow Question

To set it to null, try setting it to DBNull.Value.

Robin S.
---------------------------------------
"W.G. Ryan [MVP]" <WilliamRyan@nospam.gmail.com> wrote in message
news:ukc0tuoLHHA.4000@TK2MSFTNGP06.phx.gbl...
>I believe the problem is that DateTime is a value type and therefore
>can't be null. What value specifically do you want it to be? Do you
>need to filter or do a IsDbNull.Value check?
> "Goofy" <me@mine.com> wrote in message
> news:ua5JRAoLHHA.2140@TK2MSFTNGP03.phx.gbl...
>> Hi,
>>
>> I have a row in a dataset table which is nullable ( and also on the
>> sql
>> backend ), but how can I set it to a null.
>>
>> if I try Myrow.myDate = nothing
>>
>> when I test the row, I get "#12:00AM" why ??
>>
>> ?? IDEAS ??
>>
>>
>> --
>> Goofy
>>

>
>



  Reply With Quote
Old 03-01-2007, 06:24 AM   #4
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: DataRow Question

Goofy,

Because that is the way the debugger is representing it in VB.Net

The debugger is not showing it so nice in VB.Net as in C#.

In VB.Net is still the old representation used which is only based on USA
standards.

(While the date in Net starts in the year 1 in the first month at 12
o'clock, be aware that it is not correct because it is only a calculating
back from our Gregorian time. That time representation was not used in those
days)

Cor


"Goofy" <me@mine.com> schreef in bericht
news:ua5JRAoLHHA.2140@TK2MSFTNGP03.phx.gbl...
> Hi,
>
> I have a row in a dataset table which is nullable ( and also on the sql
> backend ), but how can I set it to a null.
>
> if I try Myrow.myDate = nothing
>
> when I test the row, I get "#12:00AM" why ??
>
> ?? IDEAS ??
>
>
> --
> Goofy
>



  Reply With Quote
Old 03-01-2007, 09:35 AM   #5
Goofy
Guest
 
Posts: n/a
Default Re: DataRow Question


Acutally it wont let you, I found a method for the column ( as I am using
Typed DataSets ) which allows me to set to null

Its all a bit fiddly if you want to enable nulls in the database, but Ive
dont it now.

Thanks to all for help.



"RobinS" <RobinS@NoSpam.yah.none> wrote in message
news:wvmdnVnEQq3kDwfYnZ2dnUVZ_sCinZ2d@comcast.com...
> To set it to null, try setting it to DBNull.Value.
>
> Robin S.
> ---------------------------------------
> "W.G. Ryan [MVP]" <WilliamRyan@nospam.gmail.com> wrote in message
> news:ukc0tuoLHHA.4000@TK2MSFTNGP06.phx.gbl...
>>I believe the problem is that DateTime is a value type and therefore can't
>>be null. What value specifically do you want it to be? Do you need to
>>filter or do a IsDbNull.Value check?
>> "Goofy" <me@mine.com> wrote in message
>> news:ua5JRAoLHHA.2140@TK2MSFTNGP03.phx.gbl...
>>> Hi,
>>>
>>> I have a row in a dataset table which is nullable ( and also on the sql
>>> backend ), but how can I set it to a null.
>>>
>>> if I try Myrow.myDate = nothing
>>>
>>> when I test the row, I get "#12:00AM" why ??
>>>
>>> ?? IDEAS ??
>>>
>>>
>>> --
>>> Goofy
>>>

>>
>>

>
>



  Reply With Quote
Old 03-01-2007, 09:36 AM   #6
Goofy
Guest
 
Posts: n/a
Default Re: DataRow Question

Hi Cor, thanks for your reply.

I found that the answer was to use the Set(ColumnNam)toNull, this way you
can then test for null instead of using the value, and subsitute the null
value when writing to the SQL SERVER.

Cheers - Goofy


"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:ugXUI%23vLHHA.2028@TK2MSFTNGP03.phx.gbl...
> Goofy,
>
> Because that is the way the debugger is representing it in VB.Net
>
> The debugger is not showing it so nice in VB.Net as in C#.
>
> In VB.Net is still the old representation used which is only based on USA
> standards.
>
> (While the date in Net starts in the year 1 in the first month at 12
> o'clock, be aware that it is not correct because it is only a calculating
> back from our Gregorian time. That time representation was not used in
> those days)
>
> Cor
>
>
> "Goofy" <me@mine.com> schreef in bericht
> news:ua5JRAoLHHA.2140@TK2MSFTNGP03.phx.gbl...
>> Hi,
>>
>> I have a row in a dataset table which is nullable ( and also on the sql
>> backend ), but how can I set it to a null.
>>
>> if I try Myrow.myDate = nothing
>>
>> when I test the row, I get "#12:00AM" why ??
>>
>> ?? IDEAS ??
>>
>>
>> --
>> Goofy
>>

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off