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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

when i passed a integer = 0 to a sqlparameter, how to change to null into db
 
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
 

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

Back
Top