Just for completeness, the Chinjoo SQL statement is likely to be something like this:
mySqlQueries.insertChatUser = "insert into the values โโof ChatUsers (UserName, Password, FirstName, LastName, sex) (?,?,?,?,?);";
This is called a parameterized insert, where each question mark represents one of its parameters. In this simple example, the order of the parameters in the parameter collection in the code should match the order of the column names in the SQL statement.
Although it is less elegant than using a function, a fix for its zero problem would look something like this for one of its parameters:
OdbcParameter LastName = new OdbcParameter ("@LastName", u.LastName);
replaced by
// if the value "null" returns DBNull, otherwise just the value OdbcParameter LastName = new OdbcParameter ("@LastName", (u.LastName == null)? System.DBNull.Value: (object) u.LastName);
At least in my code (which is slightly different) I need an internal cast to type object, because otherwise the compiler is not sure which type the operator should return ?:
Hope this helps anyone who is relatively new to parameterization, etc.
No criticism of Jinjo was implied at all - his publication helped me! Just thought that I would share for the less experienced. I am by no means an expert, so take everything I say with salt.