Re: DBnull, Date and DataAdapter

From: Marina (someone_at_nospam.com)
Date: 01/05/05


Date: Wed, 5 Jan 2005 13:03:56 -0500

NO, that is not true. Assigning DBNull.Value to a date column should work
just fine.

I think the issue is that the typed DataSet has a strongly typed column.
Whereas in a regular one, everything is of type Object, so assignment to
DBNull.Value can be compiled. I am guessing this is a compile time issue?
Your posts are very vague and do not provide all the details of your
problem. Remember, people reading this newsgroup have no idea of your
situation,you have to be very specific.

I would look for a method in the typed datatable or datarow that can set the
column to NULL. In this case, you would never be able to set a column of any
type to DBNull.Value, since they would all have a specific type (String,
Integer, etc.).

"blue_nirvana" <bluenirvana@discussions.microsoft.com> wrote in message
news:9F0922B5-24A2-4143-9667-09A5E7760A03@microsoft.com...
> I have a strongly-type dataset with a datatable from SQL Server. This
> datatable has a column called CloseDate that allows nulls. But when
trying
> to assign DbNull.Value to the column in code, I get "Value of type
> 'System.DbNull' cannot be converted to 'Date'. For example, dr.CloseDate
=
> DbNull.Value
>
> I read somewhere that you cannot update a datetime column in SQL Server
> using a DataAdapter. Is that true? If not, how do you assign a null
value
> to a datetime column in a SQL Server table using a DataAdapter?
>
> Thanks
>
> "Marina" wrote:
>
> > Are you talking about call the Update method on a dataset? What do you
mean
> > by 'using a SqlDataAdapater'?
> >
> > "blue_nirvana" <bluenirvana@discussions.microsoft.com> wrote in message
> > news:E1E2A7CB-9114-4DF8-984A-F5DC2654FA46@microsoft.com...
> > > Is there a way to assign a datetime column in SQL Server to Null using
a
> > > SQLDataAdapter? I know you can do it by calling a stored procedure
and
> > > setting a parameter equal to DBnull.Value. But it does not make since
to
> > me
> > > that you can not set a datetime column to null from a SQLDataAdapter.
> > >
> > > Thanks
> >
> >
> >



Relevant Pages

  • Re: Multiple roles?
    ... assigning a user to multiple roles. ... developers from another group to be able to to DTS over some data ... I read and thought that when assigning a user multiple ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (microsoft.public.sqlserver.security)
  • Re: Multiple roles?
    ... assigning a user to multiple roles. ... I read and thought that when assigning a user multiple ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.security)
  • Re: Why cant variable assignment occur in a data retrieval operat
    ... stored procedure and then another select statement that uses those variables. ... portion of the select statement that you are not assigning to variables - but ... > how to construct a rowset when some of the rowset should be sent to the ... >> of me think of why SQL Server would prohibit this in a stored procedure. ...
    (microsoft.public.sqlserver.programming)
  • Re: Ping an IP address on a Local Network
    ... assign all of our IP address in house, and when we are assigning a new one, ... we wish to verify that it is not already in use. ... ping a certian IP, and tell me if it is in use or not. ... to use SQL Server - have a stored procedure which does the actual pinging, ...
    (microsoft.public.dotnet.framework.aspnet)