毕业论文

打赏
当前位置: 毕业论文 > 计算机论文 >

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

时间:2016-11-22 23:24来源:毕业论文
finally { // 关闭数据库连接 DBHelper.connection.Close(); } } else if (loginType == 学生) { // 查询字符串 string sql = string.Format(select count(*) from Student where LoginId={0} and Log


                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;
                    } C#高职计算机导论考试系统设计与实现(18):http://www.youerw.com/jisuanji/lunwen_182.html
------分隔线----------------------------
推荐内容