I want to know what’s the difference between:
DBCmd.Parameters.Add("user_name", IfxType.VarChar);
DBCmd.Parameters["user_name"].Value = p_u;
and
DBCmd.Parameters.Add("user_name", p_u);
What’s the best practice here, which one is safer, and does one perform better than the other?
In the example shown, the primary difference is that it knows the type to use is explicitly
IfxType.VarChar– this might be important, depending on the exact situation, and whether IFX defaults strings asChar,VarChar, orLongVarChar. I honestly don’t know which of those it would select by default.Being explicit is usually a good idea, but there is no need to re-fetch via the indexer, since the new parameter is returned from
Add; I would probably suggest:or maybe:
where
20is the size of the parameter.