Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
663 views
in Technique[技术] by (71.8m points)

c# - Error converting data type int to tinyint

I am new to stored procedures. When i run this i get an error saying Error converting data type int to tinyint. In my C# was the following code:

mySqlcmd.CommandText = "EXECUTE PhoneNumber_Insert  @p_PhoneNumberTypeID, @p_PersonID";
mySqlcmd.Parameters.Add("@p_PhoneNumberTypeID", SqlDbType.TinyInt).Value = 1;
mySqlcmd.Parameters.Add("@p_PersonID", SqlDbType.Int).Value = "754381";
mysqlConnection.Open();
mySqlcmd.ExecuteNonQuery();
mysqlConnection.Close();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You're encountering bug 101302 in MySQL Connector/NET. There are three possible workarounds:

  1. Change your code to explicitly use MySqlDbType.Byte: mySqlcmd.Parameters.Add("@p_PhoneNumberTypeID", MySqlDbType.Byte).Value = 1;
  2. Downgrade to MySql.Data 8.0.21.
  3. Switch to MySqlConnector, which supports the same API as MySql.Data but is less buggy.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...