在 MySQl 写了一个函数,里面是 SELECT COUNT(*)这种语句。直接在 SQLyog 里 SELECT 运行,得到的结果是 1 ,这是正确的。但在 C#里偏偏得到的是 0.一开始怀疑是参数问题,于是把 sbr.Append 换成下面那句,跟 SQLyog 里一样了,可还是得到 0.求助 小白
string connSting ="server=xxx;Database='xxx';User='xxx'; Password='xxx';charset='utf8mb4';pooling=false;SslMode=none"; MySqlConnection conn = DAL.MySqlHelper.GetConnection(connSting); StringBuilder sbr = new StringBuilder(); //sbr.Append("SELECT Check('abcdefg' , '12345678');"); sbr.Append("SELECT Check('abcdefg' , '12345678');");
MySqlParameter[] parameters = { new MySqlParameter("@aaa", aaa), new MySqlParameter("@bbb", bbb) };
string cmdText = sbr.ToString(); DataTable dt = DAL.MySqlHelper.GetDataTable(connSting, CommandType.Text, cmdText, parameters); Console.WriteLine("输出"+dt.Rows[0][0].ToString());
1
abc8678 OP 试一下 markdown 代码块
··· string connSting ="server=xxx;Database='xxx';User='xxx'; Password='xxx';charset='utf8mb4';pooling=false;SslMode=none"; MySqlConnection conn = DAL.MySqlHelper.GetConnection(connSting); StringBuilder sbr = new StringBuilder(); //sbr.Append("SELECT Check('abcdefg' , '12345678');"); sbr.Append("SELECT Check('abcdefg' , '12345678');"); MySqlParameter[] parameters = { new MySqlParameter("@aaa", aaa), new MySqlParameter("@bbb", bbb) }; string cmdText = sbr.ToString(); DataTable dt = DAL.MySqlHelper.GetDataTable(connSting, CommandType.Text, cmdText, parameters); Console.WriteLine("输出"+dt.Rows[0][0].ToString()); ··· |