在vs2008+SQL2005、语言:C#坏境下using还需要做其他的修改吗?

ASP199NET 2010-10-02 10:36:09
在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 = "";
}
}
...全文
68 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ASP199NET 2010-10-02
  • 打赏
  • 举报
回复
朋友能说明一下吗?
wuyq11 2010-10-02
  • 打赏
  • 举报
回复
if(!string.IsNullOrEmpty(txtUsername.Text))
{
//DropDownList1.SeletedValue
}

62,272

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧