MySQL null/empty-string too long for VarChar(5) ?
Posted
by rlb.usa
on Stack Overflow
See other posts from Stack Overflow
or by rlb.usa
Published on 2010-04-29T20:10:31Z
Indexed on
2010/04/29
20:17 UTC
Read the original article
Hit count: 137
I have a stored procedure that takes an input var_zip varchar(5)
. My webapp calls this procedure and gives it the parameter:
cmd.Parameters.Add(new MySqlParameter("var_Zip", MySqlDbType.VarChar, 5));
cmd.Parameters["var_Zip"].Value = txtZip.Text;
txtZip is empty. So it is either giving empty string '', or null. Doesn't matter to me which. But it is throwing an error:
MySql.Data.MySqlClient.MySqlException: Data too long for column 'var_Zip' at row 1
What's going on and how can I fix it? I don't understand.
© Stack Overflow or respective owner