ExecuteReader 要求已打开且可用的连接。连接的当前状态为已关闭。
usingSystem;usingSystem.Data;usingSystem.Data.SqlClient;usingSystem.Configuration;usi...
using System;
using System.Data;
using System.Data.SqlClient;
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;
public partial class _Default : System.Web.UI.Page
{
string strname;
protected void Page_Load(object sender, EventArgs e)
{
strname= Convert.ToString(this.Session["name"]);
string strcnn = "server=.;database=学生成绩智能管理系统;user id=sa;password=sa;";
string strcmd = "SELECT DISTINCT 姓名 FROM 教师表 WHERE 教师编号 ='" + strname + " '";
SqlConnection cnn = new SqlConnection(strcnn);
SqlCommand cmd = new SqlCommand(strcmd, cnn);
SqlDataReader rdr = cmd.ExecuteReader();
if(rdr.Read())
Label1.Text = rdr[0]+"老师:";
cnn.Close();
}
} 展开
using System.Data;
using System.Data.SqlClient;
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;
public partial class _Default : System.Web.UI.Page
{
string strname;
protected void Page_Load(object sender, EventArgs e)
{
strname= Convert.ToString(this.Session["name"]);
string strcnn = "server=.;database=学生成绩智能管理系统;user id=sa;password=sa;";
string strcmd = "SELECT DISTINCT 姓名 FROM 教师表 WHERE 教师编号 ='" + strname + " '";
SqlConnection cnn = new SqlConnection(strcnn);
SqlCommand cmd = new SqlCommand(strcmd, cnn);
SqlDataReader rdr = cmd.ExecuteReader();
if(rdr.Read())
Label1.Text = rdr[0]+"老师:";
cnn.Close();
}
} 展开
3个回答
大雅新科技有限公司
2024-11-19 广告
2024-11-19 广告
这方面更多更全面的信息其实可以找下大雅新。深圳市大雅新科技有限公司从事KVM延长器,DVI延长器,USB延长器,键盘鼠标延长器,双绞线视频传输器,VGA视频双绞线传输器,VGA延长器,VGA视频延长器,DVI KVM 切换器等,优质供应商,...
点击进入详情页
本回答由大雅新科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询