mysql tinyint c#,如何处理Asp.net中的mysql tinyint字段,c#gridview?

Dear All,

I am trying to connect to mysql database.I am able to fetch the records from a table but the field type tinyint(1) convert to square box in front end. Mysql database is a shared database with 10000+ tables And have no authority to modify it. so need a generic solution to display.I tried a lot but nothing works for me. Below is the code and database entry.

Code:MySqlConnection conn = new MySqlConnection(mysqlstring);

conn.Open();

MySqlCommand cmd = conn.CreateCommand();

cmd.CommandText = "SELECT * FROM avg_product";

MySqlDataAdapter adap = new MySqlDataAdapter(cmd);

DataSet ds = new DataSet();

adap.Fill(ds);

GridView2.DataSource = ds.Tables[0].DefaultView;

GridView2.DataBind();

database:

field has values as 0 or 1.

Dataset Visualizer in visual studio showing as TRUE/FALSE.On front end in browser,Gridview shows a square box(kind of checkbox).

Please help me. Thanks in advance.

解决方案just cast the value as

select cast(tinyintcol as int) , from tbl

this should work

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值