Let's say I have a MySql stored procedure that inserts a record with some fields with zero CHAR.
In VB.NET, if I don't check Nothing (or Null in other languages), I get an exception from the db driver, so I write:
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("_name", if(name Is Nothing, "", name)).Direction = ParameterDirection.Input;
And this is the first thing I don't like; I would like to pass Nothing, and the driver knows that he must put NULL in Db. But then, in the stored procedure, I have to check the field if it is empty:
INSERT INTO mytable
(
name,
)
VALUES
(
NULLIF(_name, ''),
)
Awful, huh? I have to double check the void / void. Is there a better, more direct way?
, (.. ) , (, , -1 id, ...).