先將Web.config加入

Connection with Web.config_数据<appSettings>
Connection with Web.config_数据
<add key="strConnection_sqlserver" value="data source=HUIQIN;initial catalog=SDTE;user id=administrator;password=xiaohan;persist security info=False;packet size=4096" />
Connection with Web.config_数据
<add key="strConnection_oracle" value="user id=system;data source=kflwn;password=manager" />
Connection with Web.config_数据
</appSettings>

然後在cs中加入

Connection with Web.config_数据using System.Configuration;
Connection with Web.config_数据
public class FileConn
Connection with Web.config_sql_07Connection with Web.config_数据_08 
Connection with Web.config_sql_09{
Connection with Web.config_xml_10  
private static string strconn_sqlserver=System.Configuration.ConfigurationSettings.AppSettings["strConnection_sqlserver"];
Connection with Web.config_xml_10  
private static string strconn_oracle=System.Configuration.ConfigurationSettings.AppSettings["strConnection_oracle"];
Connection with Web.config_xml_10  
public  string adminname="";
Connection with Web.config_xml_10  
public  string adminpass="";
Connection with Web.config_xml_10  
Connection with Web.config_xml_15Connection with Web.config_oracle_16  
public static SqlConnection getConn_sqlserver()Connection with Web.config_sql_09{
Connection with Web.config_xml_10   SqlConnection conn
=new SqlConnection(FileConn.strconn_sqlserver);
Connection with Web.config_xml_10   
return conn;
Connection with Web.config_xml_20  }

Connection with Web.config_xml_10  
public static OracleConnection getConn_oracle()
Connection with Web.config_xml_15Connection with Web.config_oracle_16  
Connection with Web.config_sql_09{
Connection with Web.config_xml_10   OracleConnection conn
=new OracleConnection(FileConn.strconn_oracle);
Connection with Web.config_xml_10   
return conn;
Connection with Web.config_xml_20  }

Connection with Web.config_xml_15Connection with Web.config_oracle_16  
public static DataSet getMessage_oracle(string strSQL)Connection with Web.config_sql_09{
Connection with Web.config_xml_10   OracleConnection conn
=FileConn.getConn_oracle();
Connection with Web.config_xml_15Connection with Web.config_oracle_16   
tryConnection with Web.config_sql_09{
Connection with Web.config_xml_10    conn.Open();
Connection with Web.config_xml_10    OracleDataAdapter sda
=new OracleDataAdapter(strSQL,conn);
Connection with Web.config_xml_10    DataSet ds
=new DataSet("ds");
Connection with Web.config_xml_10    sda.Fill(ds);
Connection with Web.config_xml_10    
return ds;
Connection with Web.config_xml_20   }

Connection with Web.config_xml_15Connection with Web.config_oracle_16   
catch(OracleException e)Connection with Web.config_sql_09{
Connection with Web.config_xml_10    
throw new Exception(e.Message);
Connection with Web.config_xml_20   }

Connection with Web.config_xml_20  }

Connection with Web.config_xml_10  
public static DataSet getMessage_sqlserver(string strSQL)
Connection with Web.config_xml_15Connection with Web.config_oracle_16  
Connection with Web.config_sql_09{
Connection with Web.config_xml_10   SqlConnection conn
=FileConn.getConn_sqlserver();
Connection with Web.config_xml_10   
try
Connection with Web.config_xml_15Connection with Web.config_oracle_16   
Connection with Web.config_sql_09{
Connection with Web.config_xml_10    conn.Open();
Connection with Web.config_xml_10    SqlDataAdapter sda
=new SqlDataAdapter(strSQL,conn);
Connection with Web.config_xml_10    DataSet ds
=new DataSet("ds");
Connection with Web.config_xml_10    sda.Fill(ds);
Connection with Web.config_xml_10    
return ds;
Connection with Web.config_xml_20   }

Connection with Web.config_xml_10   
catch(System.Data.SqlClient.SqlException e)
Connection with Web.config_xml_15Connection with Web.config_oracle_16   
Connection with Web.config_sql_09{
Connection with Web.config_xml_10    
throw new Exception(e.Message);
Connection with Web.config_xml_20   }

Connection with Web.config_xml_20  }

Connection with Web.config_xml_15Connection with Web.config_oracle_16  
public static DataTable GetUsers()Connection with Web.config_sql_09{
Connection with Web.config_xml_10   DataSet ds;
Connection with Web.config_xml_15Connection with Web.config_oracle_16   
if(HttpContext.Current.Cache["usersDS"]==null)Connection with Web.config_sql_09{
Connection with Web.config_xml_10    ds
=new DataSet();
Connection with Web.config_xml_10    ds.ReadXml(HttpContext.Current.Server.MapPath(
"User.config"),XmlReadMode.Auto);
Connection with Web.config_xml_10    ds.Tables[
0].Columns["Login"].Unique=true;
Connection with Web.config_xml_10    HttpContext.Current.Cache.Insert(
"usersDS",ds,new CacheDependency(HttpContext.Current.Server.MapPath("User.config")));
Connection with Web.config_xml_20   }

Connection with Web.config_xml_10   
return((DataSet)HttpContext.Current.Cache["usersDS"]).Tables[0];
Connection with Web.config_xml_20  }