找到你要的答案

Q:MySqlHelper.ExecuteDataset returning wrong values on field Tinyint(1)

Q:mysqlhelper.executedataset返回错误值的球场上的Tinyint(1)

I have a Database with a table who has a field Tinyint(1) but isn't a boolean it's simply a number from 0 to 9.

When I extract data from this table using:

Dim ds As DataSet = MySqlHelper.ExecuteDataset(CnStr, SqlStr)

the resulted "dataset.table(0)" doesn't contain the field value.

The returned value is a boolean. So I get only "TRUE" for every value of the field and when I insert data into another table, the inserted value is 0.

I solved changing field type from Tinyint(1) to Tinyint(2) but I'd like to know if someone else faced the same problem and if is there a better way to solve.

我有一个表有一个字段字段的数据库(1)而不是一个布尔值,它只是一个数字从0到9。

使用此表提取数据时:

Dim ds As DataSet = MySqlHelper.ExecuteDataset(CnStr, SqlStr)

结果“数据集表(0)”不包含字段值。

返回值为布尔值。因此,对于字段的每个值,我只得到“true”,当我将数据插入另一个表时,插入值为0。

我解决了改变字段类型从Tinyint(1)Tinyint(2)但我想知道其他人面临同样的问题,如果有更好的方法来解决。

answer1: 回答1:

Add this to the connection string

TreatTinyAsBoolean=false

http://dev.mysql.com/doc/connector-net/en/connector-net-connection-options.html

将此添加到连接字符串

TreatTinyAsBoolean=false

http://dev.mysql.com/doc/connector-net/en/connector-net-connection-options.html

mysql  vb.net