返回TEXT列的参数化查询对于INT列始终返回零 [英] Parameterized query that returns TEXT column(s) always returns zero for INT columns
问题描述
C#mySQL ODBC问题 我的桌子
Problemt with C# mySQL ODBC My table
CREATE TABLE `account` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`fbid` varchar(30) NOT NULL,
`fbname` varchar(80) NOT NULL,
`datecreate` datetime NOT NULL,
`ipcreate` varchar(20) NOT NULL,
`datelogin` datetime NOT NULL,
`iplogin` varchar(20) NOT NULL,
`xstatus` int(2) NOT NULL,
`xverstion` int(5) NOT NULL,
`xdata` text NOT NULL,
`xitem` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
我的程序
CREATE PROCEDURE `VVVVV_getUserByFbId`(fbid2 varchar(30))
BEGIN
SELECT * from vvvvv_account where vvvvv_account.fbid=fbid2 LIMIT 1;
END
fbid2是参数(= 408301576730032) 用C#代码
fbid2 is parameter (=408301576730032) in C# code
OdbcConnection connection = new OdbcConnection(constr);
OdbcCommand cmd;
DataTable dt = new DataTable();
try
{
OpenConnection(connection);
cmd = new OdbcCommand("{call VVVVV_getUserByFbId(?)}", connection);
cmd.Parameters.AddWithValue("@fbid2", "408301576730032");
cmd.CommandType = CommandType.StoredProcedure;
OdbcDataAdapter da = new OdbcDataAdapter(cmd);
da.Fill(dt);
da.Dispose();
}
catch (Exception ex)
{
}
finally
{
CloseConnection(connection);
}
return dt;
在C#中的输出
dt.Rows[0]["id"]
始终= 0不好
dt.Rows[0]["fbname"]
="ABC"确定
output in C#
dt.Rows[0]["id"]
always = 0 Not Ok
dt.Rows[0]["fbname"]
= "ABC" OK
意味着我仍然可以从数据库正常获取数据.但是int列始终为0,varchar,datetime列即可;
means I can still get data from database normal. But int column alway = 0, varchar, datetime colume is ok;
但是,如果我将过程更改为:
BEGIN
select * from account where account.fbid='408301576730032' LIMIT 1;
END
在C#"{call VVVVV_getUserByFbId()}" -> id field = 3903
如果没有参数(fbid2)或没有文本字段(xdata,xitem)-> id
,则xstatus(int字段)将返回正常.但是,如果传递了参数或选择xdata-> id
(int字段)始终为0;
If no parameter (fbid2) or no text fied (xdata, xitem) -> id
, xstatus (int fields) return normal. But if an parameter is passed or select xdata -> id
(int fields) always = 0;
推荐答案
您在MySQL Connector/ODBC中遇到了已验证的错误,报告在这里:
You have encountered a verified bug in MySQL Connector/ODBC, reported here:
https://bugs.mysql.com/bug.php?id=97191
由于您使用的是C#,因此您可能希望查看MySQL Connector/NET是否更适合您的应用程序.
Since you are using C# you may want to see if MySQL Connector/NET works better for your application.
这篇关于返回TEXT列的参数化查询对于INT列始终返回零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!