检查登录详细信息,如果正确,则显示下一个表格 [英] check login details and if correct show next form
本文介绍了检查登录详细信息,如果正确,则显示下一个表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿,
我正在使用Visual C#2010.我有两个带有组合框的框,我已用数据库中的ID填充了该框,然后用文本框键入了引脚号.我需要做的是,如果ID和Pin号码正确就可以转到下一个表格,并且如果错误提示错误消息...我正在使用sqlcommand.到目前为止,这里是我的代码
Hey,
i am using visual c# 2010. I have got two boxes one with combo which i have filled with ID from database and then a textbox to type in pin number. what i need to do is if the ID and Pin number is correct to go to next form and if it wrong to bring error message up... i am using the sqlcommand. here my code so far
sqlCommandCheckLogin.Parameters["cardNumber"].Value = cardNo.Text;
sqlCommandCheckLogin.Parameters["PIN"].Value = pinNumber.Text;
try
{
//not sure what to put here
}
catch (Exception ex)
{
switch (ex.Message)
{
case "1":
MessageBox.Show("You have 2 attempts left");
break;
case "2":
MessageBox.Show("You have 1 attempts left");
break;
case "3":
MessageBox.Show("Your id is not blocked");
break;
}
希望有人可以提供帮助:)
hope someone can help :)
推荐答案
异常处理不应用于程序流.我将根据参数是否满足条件,使存储的proc返回标量值1或0.
Exception handling should not be used for program flow. I would have the stored proc return a scalar value, 1 or 0, based on whether the parameters meet the criteria.
if( (int)cmd.ExecuteScalar() == 1 )
{
// Next form
}
else
{
// Display error
}
这篇关于检查登录详细信息,如果正确,则显示下一个表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文