setting field value in a DataRow to Null

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...
 
M

Matt Hawley

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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top