我想用 VS2005 建立一个学生信息查询系统,但是调试的时候显示“当前上下文中不存在···”
using System;using System.Data;
using System.Configuration;
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;
using System.Data.Odbc;
public partial class _Default : System.Web.UI.Page
{
OdbcConnection cn = new OdbcConnection();
OdbcCommand cmd = new OdbcCommand();
OdbcDataReader dr;
protected void Page_Load(object sender, EventArgs e)
{
cn.ConnectionString = "连接字符串";
cn.Open();
cmd.Connection = cn;
TextBox_Snum.Text = Session["Snum"].ToString();
= "select*from学生whereSnum='" + TextBox_Snum.Text + "'";
dr = cmd.ExecuteReader();
if (dr.Read())
{
TextBox_Snum.Text = dr["Snum"].ToString();
TextBox_Ssex.Text = dr["Ssex"].ToString();
TextBox_Sage.Text = dr["Sage"].ToString();
TextBox_Sbirthday.Text = dr["Sbirthday"].ToString();
TextBox_Sdepartment.Text = dr["Sdepartment"].ToString();
}
cn.Close();
}
}
下面是错误:
错误 1 当前上下文中不存在名称“TextBox_Snum” C:\Users\valen\Documents\Visual Studio 2005\WebSites\WebSite3\Query.aspx.cs 21 9 C:\...\WebSite3\
错误 2 当前上下文中不存在名称“TextBox_Snum” C:\Users\valen\Documents\Visual Studio 2005\WebSites\WebSite3\Query.aspx.cs 22 56 C:\...\WebSite3\
错误 3 当前上下文中不存在名称“TextBox_Snum” C:\Users\valen\Documents\Visual Studio 2005\WebSites\WebSite3\Query.aspx.cs 26 13 C:\...\WebSite3\
错误 4 当前上下文中不存在名称“TextBox_Ssex” C:\Users\valen\Documents\Visual Studio 2005\WebSites\WebSite3\Query.aspx.cs 27 13 C:\...\WebSite3\
错误 5 当前上下文中不存在名称“TextBox_Sage” C:\Users\valen\Documents\Visual Studio 2005\WebSites\WebSite3\Query.aspx.cs 28 13 C:\...\WebSite3\
请问应该怎么修改哇?
[ 本帖最后由 duowanleng 于 2014-6-8 15:23 编辑 ]