谁能帮我解答? 请问在asp.net中,resource.GetString(),config集合,settings集合怎么使用 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <appSettings> <add key="ConnSql" value="server=localhost;database=study;uid=sa;pwd=sa"></add> </appSettings>-----------------------下面是使用. /// <summary> /// 打开数据库 /// </summary> public void Open() { if (conn==null) { //System.Web.HttpContext.Current.Response.Write("<BR>CONN IS NULL ,CREATE A NEW CONN2"); conn= new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnSql"]); } try { if(conn.State==System.Data.ConnectionState.Closed) { //System.Web.HttpContext.Current.Response.Write("<BR>CONN IS CLOSED2"); conn.Open(); } } catch(SqlException Ex) { //System.Web.HttpContext.Current.Response.Write("<br>err:"+Ex.Message.ToString()); System.Web.HttpContext.Current.Response.End(); // page.Response.Write ("err:"+Ex.Message.ToString()); // page.Response.End(); } finally { //System.Web.HttpContext.Current.Response.End(); } } 关于服务器运行错误 c# asp两个字符串替换 aspx页如何响应客户端Active控件的自定义事件,Js 或 Vbs的实现方式均可 关于数据库储存过程. 为什么我定义一个OleDbConnection给我这样的错误提示? DATAGRID怎么绑定自动编号的一列 谁能推荐一下能添加代码的文章管理系统 server2008 iis 怎么修改 banner? Datagrid里面的数据库列如何居左显示? 动态生成的控件,还能响应时间吗? 好急…… 页面刷新问题 用相同的连接字符串建立的连接能否并行操作?
<add key="ConnSql" value="server=localhost;database=study;uid=sa;pwd=sa"></add>
</appSettings>
-----------------------
下面是使用.
/// <summary>
/// 打开数据库
/// </summary>
public void Open()
{
if (conn==null)
{
//System.Web.HttpContext.Current.Response.Write("<BR>CONN IS NULL ,CREATE A NEW CONN2");
conn= new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnSql"]);
}
try
{
if(conn.State==System.Data.ConnectionState.Closed)
{
//System.Web.HttpContext.Current.Response.Write("<BR>CONN IS CLOSED2");
conn.Open();
}
}
catch(SqlException Ex)
{
//System.Web.HttpContext.Current.Response.Write("<br>err:"+Ex.Message.ToString());
System.Web.HttpContext.Current.Response.End();
// page.Response.Write ("err:"+Ex.Message.ToString());
// page.Response.End();
}
finally
{
//System.Web.HttpContext.Current.Response.End();
}
}