public static int ExecuteCommand(string safeSql)
{
SqlCommand cmd = new SqlCommand(safeSql, Connection);
int result = cmd.ExecuteNonQuery();
return result;
}
这是我数据辅助类的一个方法
我现在在数据访问层查询用户名和密码 让他返回给逻辑层 逻辑层的方法是Boolean类型的 如果大于1的话返回true 给表示层 但是现在我这个数据访问层这么写 我运行时候 他没有反应 我感觉是不是我sql语句有问题?
public static int BackUser(string name, string pwd)
{
int result = 0;
string sql = "select * from YongHu where U00002=" + "'name'" + " and U00003=" + "'pwd'";
result = DBHelper.ExecuteCommand(sql);
return result;
}希望大家帮帮忙 我是新手- -
{
SqlCommand cmd = new SqlCommand(safeSql, Connection);
int result = cmd.ExecuteNonQuery();
return result;
}
这是我数据辅助类的一个方法
我现在在数据访问层查询用户名和密码 让他返回给逻辑层 逻辑层的方法是Boolean类型的 如果大于1的话返回true 给表示层 但是现在我这个数据访问层这么写 我运行时候 他没有反应 我感觉是不是我sql语句有问题?
public static int BackUser(string name, string pwd)
{
int result = 0;
string sql = "select * from YongHu where U00002=" + "'name'" + " and U00003=" + "'pwd'";
result = DBHelper.ExecuteCommand(sql);
return result;
}希望大家帮帮忙 我是新手- -
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText =@"select * from UserInfo where UserName=@UserName
and UserPwd=@UserPwd";
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add(new SqlParameter("@UserName",username));
cmd.Parameters.Add(new SqlParameter("@UserPwd",userpassword)); SqlDataReader reader = cmd.ExecuteReader();
ExecuteScalar