您的位置:首页 > 其它

我想用 VS2005 建立一个学生信息查询系统,但是调试的时候显示“当前上下文中不存在···”

2014-06-29 23:09 375 查看
程序代码:

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();
cmd.CommandText = "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();

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐