How to insert a integer = 0 into database to be null

  • Thread starter Thread starter Guest
  • Start date Start date
Given your limited description it at first appears that you have two options
but it is hard to be more specific than this with such a short description.
Are you using SQL Server? Oracle? Access?

Possiblities:
1.) ADO.NET
if(value==0)
Parameter.Value = DBNull.Value
else
Parameter.Value = Value

2.) SQL
modify your SQL statement so that the parameter value is tested through a
method such as the CASE statement
ie: column = (CASE WHEN @parameter=0 THEN NULL ELSE @parameter END)


Joe said:
when i passed a integer = 0 to a sqlparameter, how to change to null into
db
 
Back
Top