62,025
社区成员
发帖
与我相关
我的任务
分享
public void Open()
{
if (object.Equals(Connection, null))
{
Connection = new OleDbConnection();
}
if (Connection.State.ToString() != "Open")
{
// Connection.ConnectionString = ConfigurationSettings.AppSettings["MsSql"];
Connection.ConnectionString = ConfigurationManager.AppSettings["MsSqls"]; try
{
Connection.Open();
}
catch (OleDbException e)
{
// Connection.Dispose();
throw new Exception(e.ToString());
}
}
}
<configuration>
<appSettings>
<!--数据库设置Start-->
<!--Access or MsSql-->
<add key="DBType" value="MsSql"/>
<add key="MsSql" value="Data Source=.;Initial Catalog=SRMDB2;User ID=sa;Password=123456"/>
<add key="MsSqls" value="Data Source=.;Initial Catalog=SRMDB2;Persist Security Info=True;User ID=sa;Password=123456"/>
...