我得到一个
“ConnectionString”引发了“System.Configuration.ConfigurationErrorsException”类型的异常
每次我尝试运行我的 WinForm 时。
知道如何解决吗?
这是我的 C# 代码:
public class DB
{
/// <summary>
///
/// </summary>
public static string ConnectionString
{
get
{
string connStr = ConfigurationManager.ConnectionStrings["Stoica Mihai"].ConnectionString;
OracleConnectionStringBuilder sb = new OracleConnectionStringBuilder(connStr);
//sb.ApplicationName = ApplicationName ?? sb.ApplicationName;
//sb.ConnectTimeout = (ConnectionTimeout > 0) ? ConnectionTimeout : sb.ConnectTimeout;
return sb.ToString();
}
}
/// <summary>
/// Returns an opened connection to the database
/// </summary>
/// <returns></returns>
public static OracleConnection GetSqlConnection()
{
OracleConnection conn = new OracleConnection(ConnectionString);
conn.Open();
return conn;
}
/// <summary>
/// Override the connection timeout
/// </summary>
public static int ConnectionTimeout { get; set; }
/// <summary>
/// Used to override the name of the application
/// </summary>
public static string ApplicationName { get; set; }
}