存储过程代码:
CREATE PROCEDURE getYzPwd
@验证密码 [VarChar](50)
AS
begin
select * from 用户 where 验证密码=@验证密码
end
GO
c#注册窗体代码,我的用户表包括 用户名 密码 验证密码(可空),所以我想定义一个通过要输入一个正确的验证密码才能注册。代码:
public bool Checkyanzheng()
{
bool y = true;
Dbhelper con = new Dbhelper();
SqlCommand com = new SqlCommand("getYzPwd", con.cn);
com.CommandType = CommandType.StoredProcedure;
SqlParameter prams = new SqlParameter("@验证密码", SqlDbType.VarChar, 50);
prams.Value = txtYanZhengPwd.Text;
com.Parameters.Add(prams);
con.cn.Open();
int i = (int)com.ExecuteNonQuery();
if (i > 0)
{
lblyzError.Visible = false;
y = true;
MessageBox.Show("注册成功", "提示");
}
else
{
lblyzError.Visible = true;
MessageBox.Show("注册失败", "提示");
y = false;
}
con.cn.Close();
return y;
}
但缕缕失败,明明我输入的密码都是正确的,但都是弹出注册失败的信息。
求高手解答!
CREATE PROCEDURE getYzPwd
@验证密码 [VarChar](50)
AS
begin
select * from 用户 where 验证密码=@验证密码
end
GO
c#注册窗体代码,我的用户表包括 用户名 密码 验证密码(可空),所以我想定义一个通过要输入一个正确的验证密码才能注册。代码:
public bool Checkyanzheng()
{
bool y = true;
Dbhelper con = new Dbhelper();
SqlCommand com = new SqlCommand("getYzPwd", con.cn);
com.CommandType = CommandType.StoredProcedure;
SqlParameter prams = new SqlParameter("@验证密码", SqlDbType.VarChar, 50);
prams.Value = txtYanZhengPwd.Text;
com.Parameters.Add(prams);
con.cn.Open();
int i = (int)com.ExecuteNonQuery();
if (i > 0)
{
lblyzError.Visible = false;
y = true;
MessageBox.Show("注册成功", "提示");
}
else
{
lblyzError.Visible = true;
MessageBox.Show("注册失败", "提示");
y = false;
}
con.cn.Close();
return y;
}
但缕缕失败,明明我输入的密码都是正确的,但都是弹出注册失败的信息。
求高手解答!
解决方案 »
- 关于WPF中WindowsFormsHost的几个问题
- C#绘图时,当画图形时,前一次画的图形就消失了,而且比如画直线后,再选择矩形,会自动画出矩形,这个矩形就是根据之前的直线的两个端点自动出现的,该怎么解决呢
- 如果要更改普通的textboxcell 变成 DataGridViewComboBoxCell ,有什么办法可以实现呢?
- VS 2003下的工程转到2005下不支持,该语句<body MS_POSITIONING="GridLayout">不能编译通过!!!360度跪求
- 如何將picturebox上以graphic所繪的圖形,儲存于bitmap內,待以後再load(回復)于picturebox內
- 如何解决StreamWrite中一个问题
- C# 技术交流群,前一阵换群有没有即使转群的朋友们进来看下号码
- 在winfrom 中用DataGrid编辑和更新出错---请高手指教.在线等--问题解决立刻给分
- 是否一定要用DataSet.Tables.Add()?
- 不可访问“System.Xml.XmlTextReader.XmlTextReader()”,因为它受保护级别限制,为什么啊?
- treeView
- 添加数据
只要不小于0就算成功了。
if (i >= 0)
{
lblyzError.Visible = false;
y = true;
MessageBox.Show("注册成功", "提示");
}
用com.executescalar()
@验证密码 [VarChar](50)
AS
begin
select COUNT(*) from 用户 where 验证密码=@验证密码
end
GO