setting field value in a DataRow to Null

  • Thread starter Thread starter Nikhil Patel
  • Start date Start date
N

Nikhil Patel

Hi all,
I need to set a field value of a DataRow to null(SQL Server Null
equivalent) in C#. I tried following but it gave me an error:
rowProposal["TotalCost"] = DBNull;

The error: 'System.DBNull denotes a class where a variable was expected.

So How can I set this field to SQL Server Null?

Thanks...
 
You need to use DBNull.Value instead of just DBNull.

Matt Hawley, MCAD .NET
http://www.eworldui.net

Hi all,
I need to set a field value of a DataRow to null(SQL Server Null
equivalent) in C#. I tried following but it gave me an error:
rowProposal["TotalCost"] = DBNull;

The error: 'System.DBNull denotes a class where a variable was expected.

So How can I set this field to SQL Server Null?

Thanks...



[microsoft.public.dotnet.framework.aspnet]
 
Back
Top