C#高职计算机导论考试系统设计与实现(18)_毕业论文

毕业论文移动版

毕业论文 > 计算机论文 >

C#高职计算机导论考试系统设计与实现(18)


                finally
                {
                    // 关闭数据库连接
                    DBHelper.connection.Close();
                }
            }
            else if (loginType == "学生")
            {
                // 查询字符串
                string sql = string.Format("select count(*) from Student where LoginId='{0}' and LoginPwd='{1}'",
                                    loginId, loginPwd);
                // 测试数据库连接
                try
                {
                    // 创建 Command 对象
                    SqlCommand command = new SqlCommand(sql, DBHelper.connection);

                    // 打开数据库连接
                    DBHelper.connection.Open();

                    // 验证是否为合法用户名
                    int count = (int)command.ExecuteScalar();
                    if (count < 1)
                    {
                        message = "用户名或密码不存在!\n\n\n★PS:若多次尝试都无法成功,请速速联系授课老师,因为你可能是没有考试资格的缘故!!!";
                        return false;
                    }
                    else
                    {
                        return true;
                    } (责任编辑:qin)