Value was either too large or too small for an unsigned byte
Posted by: archilk
Date: January 22, 2007 04:59AM

Hi dear fellow MySQL developers,

I have the following DB table:

CREATE TABLE `CoolDB`.`user_info` (
`Id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(256) NOT NULL,
PRIMARY KEY(`Id`)
)
ENGINE = InnoDB;

I also added a SPROC:

CREATE PROCEDURE CoolDB.AddUser (in userName VARCHAR(256))
BEGIN
INSERT INTO CoolDB.user_info (Name) Values(userName);
END;

I am executing the following .NET code to call the above SPROC to add a user:
[I omitted error checking code for clarity]

using (MySqlConnection connection = new MySqlConnection(connectionString))
{
MySqlCommand command = new MySqlCommand();
command.CommandType = CommandType.StoredProcedure;
command.Connection = connection;
command.CommandText = "CoolDB.AddUser";
command.Parameters.Add("?userName", MySqlDbType.VarChar).Value = userName;

try
{
connection.Open();
command.ExecuteNonQuery();
}
catch (MySqlException ex)
{
string foo = ex.Message;
}
finally
{
connection.Close();
}
}

When I run this code I get an exception "Value was either too large or too small for an unsigned byte". If I change my CoolDB.Name column to be of type VARCHAR(128) (instead of 256) then everything works fine. Is there a bug with VARCHAR(256) size or am I doing something wrong? (Note: I am using .NET connector 1.0.8).

Regards,
Archil



Edited 1 time(s). Last edit at 01/22/2007 05:00AM by archilk.

Options: ReplyQuote


Subject
Written By
Posted
Value was either too large or too small for an unsigned byte
January 22, 2007 04:59AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.