在vs2008+SQL2005、语言:C#坏境下using还需要做其他的修改吗?
在vs2008+SQL2005、语言:C#坏境下using还需要做其他的修改吗?
这是一个login页面的源代码:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
protected void btn_login_Click(object sender, EventArgs e)
{
string strcmd = "";
int i;
DataAcess mydataAcess = new DataAcess( )
if (txtUsername.Text.Trim() != "" && txtPassword.Text.Trim() != "")
{
if (DropDownList1.Text == "管理员")
{
strcmd = "select count(*) from admin where 用户名='" + txtUsername.Text + "' and 密码='" + txtPassword.Text + "'";
temp = 1;
}
if (DropDownList1.Text == "教师")
{
strcmd = "select count(*) from teacher where 教师编号='" + txtUsername.Text + "' and 密码='" + txtPassword.Text + "'";
temp = 2;
}
if (DropDownList1.Text == "学生")
{
strcmd = "select count(*) from student where 学号='" + txtUsername.Text + "' and 密码='" + txtPassword.Text + "'";
temp = 3;
}
i = mydataAcess.ExecuteScalar(strcmd);
if (i == 1)
{
Session["Username"] = txtUsername.Text.ToString();
if (temp == 1)
Response.Redirect("admin//stuadmin.aspx");
if (temp == 2)
Response.Redirect("teacher//index.aspx");
if (temp == 3)
Response.Redirect("student//index.aspx");
}
else
Response.Write("<script LANGUAGE='javascript'>alert('账号或密码错误!');history.go(-1);</script>")
}
else
{
Response.Write("<script LANGUAGE='javascript'>alert('请输入账号或密码!');history.go(-1);</script>");
txtUsername.Text = "";
txtPassword.Text = "";
}
}