我已经坚持了几天了,我似乎无法找到解决方案。我正在尝试连接到 MySQL 数据库并使用 C# ASP.NET 和 MVC4 验证登录页面的用户。这是我正在尝试使用的代码。调试器在 MysqlDataReader 行给了我错误。我得到的错误是:
存储过程是:
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetUser`(
in search varchar (200))
BEGIN
SELECT * FROM GetUser
WHERE id;
END
.
public bool isValid(string username, string password) // Used to validate user
{
using (MySqlConnection connection = DBConnect.getconnection())
{
using (MySqlCommand cmd = new MySqlCommand("GetUser", connection))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new MySqlParameter("?search", MySqlDbType.VarChar));
cmd.Parameters["?search"].Value = "%" + "" + "%";
cmd.Parameters["?search"].Direction = ParameterDirection.Input;
MySqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Response.Redirect("Index");
}
else
{
Response.Redirect("LogIn");
}
}
}
bool isValid = false;
return isValid;
}
我得到的错误是:
An exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll but was not handled in user code
Additional information: Table 'systemusers.getuser' doesn't exist