Re: DBnull, Date and DataAdapter

From: blue_nirvana (bluenirvana_at_discussions.microsoft.com)
Date: 01/05/05


Date: Wed, 5 Jan 2005 09:53:04 -0800

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: Problem with using BETWEEN for date range...
    ... In SQL Server because we don't have a DATE data type we need to store dates ... Rich coming from the guy who doesn't use the standard format himself. ... clearly trade data with that tradetime? ... because there is a DATETIME column which has a time on it. ...
    (comp.databases.ms-sqlserver)
  • Re: Cannot update identity column
    ... course to learn something about SQL Server! ... Using IDENTITY (the proper term for an "autonumber" column). ... a DATETIME column to represent the date ... The short term fix is to use DBCC CHECKIDENT to change the identity ...
    (microsoft.public.sqlserver.programming)
  • Re: SQL Server Upgrade wizard
    ... The data transfer fails on the datetime column. ... When get paid, I laugh all the ... I need to copy my data to SQL server BEFORE ... the two methods of transferring and upsizing data to SQL server? ...
    (microsoft.public.access.externaldata)
  • Re: converting SQLTable to Excel Sheet
    ... open it the datetime column and int columns are not getting recognised. ... and Excel is not likely to understand that. ... I don't think you should export to an .xls file. ... Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books ... ...
    (comp.databases.ms-sqlserver)
  • Re: DBnull, Date and DataAdapter
    ... HTH, ... > Is there a way to assign a datetime column in SQL Server to Null using a ... > that you can not set a datetime column to null from a SQLDataAdapter. ...
    (microsoft.public.dotnet.framework.adonet)