sunflower Asked: 2020-03-09 08:29:40 +0800 CST 2020-03-09 08:29:40 +0800 CST 2020-03-09 08:29:40 +0800 CST Convert varchar value to tinyint? 772 I have a value in a textbox (varchar) in an asp .net webform and I need to compare it to a sql tinyint value. What would be the way? Thank you Cheers c# 1 Answers Voted Best Answer Juan Salvador Portugal 2020-03-10T04:10:20+08:002020-03-10T04:10:20+08:00 I recommend you read this article. https://docs.microsoft.com/en-us/sql/relational-databases/clr-integration-database-objects-types-net-framework/mapping-clr-parameter-data There you can see the data relationship between the different SQL and C# data types In your case, to be able to insert tinyint you must use Byte string a = "1"; Byte b; b = Convert.ToByte(a); Byte c = 0; if(b>c){ ....... } I hope it helps you. Regards
I recommend you read this article.
https://docs.microsoft.com/en-us/sql/relational-databases/clr-integration-database-objects-types-net-framework/mapping-clr-parameter-data
There you can see the data relationship between the different SQL and C# data types
In your case, to be able to insert tinyint you must use Byte
I hope it helps you. Regards