asp.net使用参数返回错误的值

时间:2016-11-01 21:01:22

标签: c# mysql

所以我有一个搜索返回工作......但它没有在数据库中找到确切的条目......

16/11/01 21:50:11 DEBUG zookeeper.ClientCnxn: Reading reply sessionid:0x1579b929b8e0d06, packet:: clientPath:null serverPath:null finished:false header:: 65,4  replyHeader:: 65,4297753995,-101  request:: '/hbase/meta-region-server,F  response::  
16/11/01 21:50:11 DEBUG zookeeper.ZKUtil: hconnection-0x42591130-0x1579b929b8e0d06, quorum=149.202.86.142:2181, baseZNode=/hbase Unable to get data of znode /hbase/meta-region-server because node does not exist (not an error)
16/11/01 21:50:12 DEBUG zookeeper.ClientCnxn: Reading reply sessionid:0x1579b929b8e0d06, packet:: clientPath:null serverPath:null finished:false header:: 66,4  replyHeader:: 66,4297753995,-101  request:: '/hbase/meta-region-server,F  response::  
16/11/01 21:50:12 DEBUG zookeeper.ZKUtil: hconnection-0x42591130-0x1579b929b8e0d06, quorum=149.202.86.142:2181, baseZNode=/hbase Unable to get data of znode /hbase/meta-region-server because node does not exist (not an error)

当我搜索" e7af78997ef220a557c97a1a4c11e0c2" 这是一个人员ID时,它会返回" fa32f7c456b368e17a278f3b165a550d" 这完全是不同的人ID。

如果我将查询更改为MySqlConnection con = new MySqlConnection(dbConnection); MySqlCommand cmd; con.Open(); MySqlDataReader dbReader; string cmdText = "SELECT `BanID`, `GUID`, `BanTime`, `Reason`, `BanType`, `Proof` FROM `a3bans`.`bans` WHERE `GUID` LIKE @pGUID"; cmd = new MySqlCommand(cmdText, con); cmd.Parameters.AddWithValue("@pGUID", "%" + bans.GuidOrIP + "%"); GUID WHERE,则会返回= @prmGUID"值。

我做错了什么,它不会返回我正在寻找的字符串?

2 个答案:

答案 0 :(得分:0)

MySqlConnection con = new MySqlConnection(dbConnection);
 MySqlCommand cmd;
 con.Open();
 MySqlDataReader dbReader;
 string cmdText = "SELECT `BanID`, `GUID`, `BanTime`, `Reason`, `BanType`, `Proof` FROM `a3bans`.`bans` WHERE  `GUID` LIKE '%@pGUID%'";

cmd = new MySqlCommand(cmdText, con);
SqlParameter param  = new SqlParameter();
param.ParameterName = "@pGUID";
param.Value         = bans.GuidOrIP;
cmd.Parameters.Add(param);

通过使用此代码,它将在表中查找相同的bans.pGUID,然后返回结果。 试试吧。

答案 1 :(得分:0)

它实际上与此无关,大声笑我有两个非常相似的变量,让它们混淆了......

感谢帮助人员