日期:2014-05-17  浏览次数:20426 次

当前上下文中不存在名称“pwd”
vs2008里调试有错,错误为:
错误 1 当前上下文中不存在名称“pwd” F:\diannaojxc\login.aspx.cs 26 13 F:\...\diannaojxc\
错误 2 当前上下文中不存在名称“username” F:\diannaojxc\login.aspx.cs 26 32 F:\...\diannaojxc\
错误 3 当前上下文中不存在名称“dlType” F:\diannaojxc\login.aspx.cs 32 13 F:\...\diannaojxc\
错误 4 当前上下文中不存在名称“username” F:\diannaojxc\login.aspx.cs 35 63 F:\...\diannaojxc\
错误 5 当前上下文中不存在名称“pwd” F:\diannaojxc\login.aspx.cs 35 103 F:\...\diannaojxc\
错误 6 当前上下文中不存在名称“dlType” F:\diannaojxc\login.aspx.cs 38 13 F:\...\diannaojxc\
错误 7 当前上下文中不存在名称“username” F:\diannaojxc\login.aspx.cs 41 66 F:\...\diannaojxc\
错误 8 当前上下文中不存在名称“pwd” F:\diannaojxc\login.aspx.cs 41 107 F:\...\diannaojxc\
错误 9 当前上下文中不存在名称“dlType” F:\diannaojxc\login.aspx.cs 45 13 F:\...\diannaojxc\
错误 10 当前上下文中不存在名称“username” F:\diannaojxc\login.aspx.cs 48 66 F:\...\diannaojxc\
错误 11 当前上下文中不存在名称“pwd” F:\diannaojxc\login.aspx.cs 48 107 F:\...\diannaojxc\
错误 12 当前上下文中不存在名称“username” F:\diannaojxc\login.aspx.cs 61 39 F:\...\diannaojxc\
错误 13 当前上下文中不存在名称“dlType” F:\diannaojxc\login.aspx.cs 63 35 F:\...\diannaojxc\
代码:
login.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       // if (!IsPostBack)
     //   {
           

     //   }
    }

  
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (pwd.Value == "" || username.Value == "")
        {
            Response.Write("<script>javascript:alert('请输入完整');history.back();</script>");
            Response.End();
        }
        string sql=null;
        if (dlType.Value == "管理员")
   {

            sql = "select * from allusers where username='" + username.Value.Trim() + "' and pwd='" + pwd.Value .Trim() + "'";
                
    }
        if (dlType.Value == "教师")
        {

            sql = "select * from jiaoshixinxi where gonghao='" + username.Value.Trim() + "' and mima='" + pwd.Value.Trim() + "'";

        }

        if (dlType.Value == "学生")