并非所有的代码路径都返回值.程序应该怎么改?
public int CheckUser()
{
if (this.tbxUserName.Text == "")
{
MessageBox.Show("用户名不能为空!", "错误");
}
else if (this.tbxPassWord.Text == "")
{
MessageBox.Show("密码不能为空!", "错误");
}
else
{
string str = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
SqlConnection conn = new SqlConnection(str);
SqlCommand cmd = new SqlCommand("Login", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter UserName = new SqlParameter("@username", SqlDbType.VarChar, 50);
UserName.Value = this.tbxUserName.Text;
cmd.Parameters.Add(UserName);
SqlParameter PassWord = new SqlParameter("@pwd", SqlDbType.VarChar, 50);
UserName.Value = this.tbxPassWord.Text;
cmd.Parameters.Add(PassWord);
SqlParameter sp = new SqlParameter("@return", SqlDbType.Int, 4);
sp.Direction = ParameterDirection.Output;
cmd.Parameters.Add(sp);
try
{
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
int n = (int)(sp.Value);
return n;
}
catch
{
return 0;
}
}
}
private void button1_Click(object sender, EventArgs e)
{
if (CheckUser() > 0)
{
PicManager pic = new PicManager();
pic.Show();
this.Hide();
}
else
{
MessageBox.Show("用户名不能为空");
}
}
...全文
相关推荐
基于Python的自动改卷程序的设计与实现.pdf
程序的关键技术点: - 文件路径处理:程序需要根据不同的班级信息动态构建文件路径以读取对应的Excel文件。 - 数据比较:比较学生答案和标准答案是否一致,并根据结果加减分数。
节约法(车路路径问题VRP)的Matlab程序代码
"该资源提供了一个使用Matlab解决车辆路径问题(Vehicle Routing Problem, VRP)的程序代码,主要采用节约法(Saving Method)。程序包含详细注释,用户可以根据
c++_获取当前程序(EXE)所在的路径
获取应用程序所在目录时,应避免使用`GetCurrentDirectory`,因为该函数返回的是当前工作目录,而并非程序的启动位置。
log4j动态改日志路径[代码]
在Java代码中,开发者可以通过获取到Log4j的FileAppender对象,并调用setFile方法来实现路径的动态更改。
vb编写的批量改后缀名程序有源代码
通过学习和理解这个VB批量改后缀名程序的源代码,开发者不仅可以掌握如何在VB中处理文件和目录,还能了解如何设计和实现一个具有用户交互功能的应用程序。


