Set a row value to Null

2141
3
11-05-2011 08:06 PM
BerndtNording
New Contributor III
How does one set a row value to null?

pRow.Value(i) = "" sets it to an empty string
pRow.Value(i) = nothing also sets it to an empty string
pRow.Value(i) = system.dbnull  generates an error

in the field calculator you can create an expression like Field1 = null and it will set the values to Null, but how do you do it in .NET?
0 Kudos
3 Replies
RichardFairhurst
MVP Honored Contributor
How does one set a row value to null?

pRow.Value(i) = "" sets it to an empty string
pRow.Value(i) = nothing also sets it to an empty string
pRow.Value(i) = system.dbnull  generates an error

in the field calculator you can create an expression like Field1 = null and it will set the values to Null, but how do you do it in .NET?


Check out this link.  It seems to list a way to generate a null value, at least for date fields.  Let me know if this points you in the right direction.
0 Kudos
RichardFairhurst
MVP Honored Contributor
See also this link for string fields.  It seems you should use

field.value = dbNull.value.
0 Kudos
JamesCrandall
MVP Frequent Contributor
How does one set a row value to null?

pRow.Value(i) = "" sets it to an empty string
pRow.Value(i) = nothing also sets it to an empty string
pRow.Value(i) = system.dbnull  generates an error

in the field calculator you can create an expression like Field1 = null and it will set the values to Null, but how do you do it in .NET?



Try:


pRow.Value(i) = System.DBNull.Value

0 Kudos