Camillia
asked on
Using IsDBNull for this line
I have this line of code but i get a null reference when i run the code. I need to ..for example, say if it's null..replace with a default value or leave blank..how can I do this?
cmd.Parameters.Add("@ShipD ate", SqlDbType.DateTime).Value = item.Shipment.CreatedOn;
I get a null for item.Shipment.Createon...
cmd.Parameters.Add("@ShipD
I get a null for item.Shipment.Createon...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that's like the IIF in VB.net, i think. Let me try.
ASKER
DBNull.Value for "defaultvalue"?
no for the null check
with minor change depending if Nulls allowed in DB Field
cmd.Parameters.Add("@ShipD ate", SqlDbType.DateTime).Value = (item.Shipment.CreatedOn == null) ? (object)DBNull.Value : item.Shipment.CreatedOn;
cmd.Parameters.Add("@ShipD
ASKER