MySqlDBType equivalent of SqlDBType.Char in routines (stored procedures)
-
I have searched on the net for an answer to this, and in Code Project and I can't seem to find a definite answer. Plenty about data types in tables but little or nothing about stored procedure parameters. I am converting an SQL Server based program to run with MySql and one of the tables accessed by a procedure (routine) has a field that is the char type that is used as one the parameter fields. In procedures in SQL Server there is the SqlDBType.Char but there does not appear to be any equivalent of that in MySql (5.5) Should I just use VarChar?
-
I have searched on the net for an answer to this, and in Code Project and I can't seem to find a definite answer. Plenty about data types in tables but little or nothing about stored procedure parameters. I am converting an SQL Server based program to run with MySql and one of the tables accessed by a procedure (routine) has a field that is the char type that is used as one the parameter fields. In procedures in SQL Server there is the SqlDBType.Char but there does not appear to be any equivalent of that in MySql (5.5) Should I just use VarChar?
char(10) will deliver a string 10 characters long, padded with spaces if there is no data, varchar will deliver just the data. You need to asses whether this change will affect your output. I only use char for single character fields.
Never underestimate the power of human stupidity RAH
-
char(10) will deliver a string 10 characters long, padded with spaces if there is no data, varchar will deliver just the data. You need to asses whether this change will affect your output. I only use char for single character fields.
Never underestimate the power of human stupidity RAH
Thanks for responding. I understand the differences between char and varchar but what I am trying to find out is what type I should give a parameter. I have a char(1) field that accepts data in a routine. In an SQL Server stored procedure I would give this the SqlDBType.Char type. There seems to be no equivalent in MySQL so my question was do I just use MySqlDBType.VarChar?
-
Thanks for responding. I understand the differences between char and varchar but what I am trying to find out is what type I should give a parameter. I have a char(1) field that accepts data in a routine. In an SQL Server stored procedure I would give this the SqlDBType.Char type. There seems to be no equivalent in MySQL so my question was do I just use MySqlDBType.VarChar?
I think you have to use a varchar, I have no experience with MySQL, but you need to be aware that the field could end up as a null or an empty string which it cannot do if it were a char. So your client needs to be aware of this and deal with it. Reality is that you are probably using the field as a flag and it wall ALWAYS have a value.
Never underestimate the power of human stupidity RAH
-
I think you have to use a varchar, I have no experience with MySQL, but you need to be aware that the field could end up as a null or an empty string which it cannot do if it were a char. So your client needs to be aware of this and deal with it. Reality is that you are probably using the field as a flag and it wall ALWAYS have a value.
Never underestimate the power of human stupidity RAH
Pretty much what I was thinking. Thanks for you help.