初学:这句话什么意思
privatevoidGridViewBind(){ysconncon1=newysconn();stringconnStr=ConfigurationManager.C...
private void GridViewBind() { ysconn con1 = new ysconn(); string connStr = ConfigurationManager.ConnectionStrings["connection_string"].ConnectionString; string SqlStr = "Select a.*,b.description FROM test01 a,xueli b where a.xueli=b.code and a.id<1000 and a.id>200"; DataSet ds = new DataSet(); try { SqlConnection conn = new SqlConnection(connStr); if (conn.State.ToString() == "Closed") conn.Open(); SqlDataAdapter da = new SqlDataAdapter(SqlStr, conn); da.Fill(ds, "test01"); if (conn.State.ToString() == "Open") conn.Close(); GridView1.DataSource = ds.Tables[0].DefaultView; GridView1.DataBind(); } catch (Exception ex) { Response.Write("数据库错误,错误原因:" + ex.Message); Response.End(); } }这句话什么意思? string connStr = ConfigurationManager.ConnectionStrings["connection_string"].ConnectionString;
展开
1个回答
展开全部
string connStr = ConfigurationManager.ConnectionStrings["connection_string"].ConnectionString;这句话的意思就是二楼说的。SqlConnection conn = new SqlConnection(connStr); SqlDataAdapter da = new SqlDataAdapter(SqlStr, conn);这里可以改为 if (conn.State.ToString() == "Closed") conn.Open();if (conn.State.ToString() == "Closed") conn.Open(); SqlDataAdapter da = new SqlDataAdapter(SqlStr, conStr); 查看原帖>>
希望采纳
希望采纳
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询