asp.net 的connectionstring的属性尚未初始化
publicpartialclassMemberManage_Register:System.Web.UI.Page{SqlOperatesqloperate=newSq...
public partial class MemberManage_Register : System.Web.UI.Page
{
SqlOperate sqloperate = new SqlOperate();
SqlConnection sqlconn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
sqlconn.Open();//这里说connectionstring的属性尚未初始化
string sqlstr = "select * from tb_Image";
SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlconn);
DataSet myds = new DataSet();
myda.Fill(myds, "tb_Image");
ddlPhoto.DataSource = myds.Tables["tb_Image"];
ddlPhoto.DataTextField = "Image";
ddlPhoto.DataBind();
imgPhoto.ImageUrl = ddlPhoto.SelectedValue;
sqlconn.Close();
}
}
我是菜鸟,刚学asp.net 我是从其它地方引用过来的是一个注册页面。这是代码一部分请高手指点下十分感谢!
Web.Config里面配置啊?我是从别人那里引用过来的,请你指点下十分感谢啊! 展开
{
SqlOperate sqloperate = new SqlOperate();
SqlConnection sqlconn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
sqlconn.Open();//这里说connectionstring的属性尚未初始化
string sqlstr = "select * from tb_Image";
SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlconn);
DataSet myds = new DataSet();
myda.Fill(myds, "tb_Image");
ddlPhoto.DataSource = myds.Tables["tb_Image"];
ddlPhoto.DataTextField = "Image";
ddlPhoto.DataBind();
imgPhoto.ImageUrl = ddlPhoto.SelectedValue;
sqlconn.Close();
}
}
我是菜鸟,刚学asp.net 我是从其它地方引用过来的是一个注册页面。这是代码一部分请高手指点下十分感谢!
Web.Config里面配置啊?我是从别人那里引用过来的,请你指点下十分感谢啊! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询