我试图在app.config文件中存储我的实体框架连接字符串。
string con = "metadata=res://*/OtomasyonDB.csdl|res://*/OtomasyonDB.ssdl|res://*/OtomasyonDB.msl;provider=FirebirdSql.Data.FirebirdClient;provider connection string="Database=" + Application.StartupPath + "\\" + "DATABASE\\" + textEdit10.Text + "\\" + DateTime.Now.Year + "\\DATABASE.FDB" + ";data source=localhost;user id=SYSDBA;password=masterkey;server type=0"";
当我保存到app.config文件
时,这是我的连接字符串 metadata=res://*/OtomasyonDB.csdl|res://*/OtomasyonDB.ssdl|res://*/OtomasyonDB.msl;provider=FirebirdSql.Data.FirebirdClient;provider connection string=&ampquot;Database=C:\Users\Erdal\Documents\Visual Studio 2015\Projects\MUHASEBESON\DXApplication4\bin\Debug\DATABASE\444\2017\DATABASE.FDB;data source=localhost;user id=SYSDBA;password=masterkey;server type=0"
它的"
看似"
真正的连接字符串必须如下所示。
metadata=res://*/OtomasyonDB.csdl|res://*/OtomasyonDB.ssdl|res://*/OtomasyonDB.msl;provider=FirebirdSql.Data.FirebirdClient;provider connection string="Database=C:\Users\Erdal\Documents\Visual Studio 2015\Projects\MUHASEBESON\DXApplication4\bin\Debug\566\2017\DATABASE.FDB;data source=localhost;user id=SYSDBA;password=masterkey;server type=0"
我尝试将字符串替换为函数,但我发送的是真正的连接字符串,当它保存到app.config文件时,它会转换为此。
这是我的保存代码
string con = "metadata=res://*/OtomasyonDB.csdl|res://*/OtomasyonDB.ssdl|res://*/OtomasyonDB.msl;provider=FirebirdSql.Data.FirebirdClient;provider connection string="Database=" + Application.StartupPath + "\\" + "DATABASE\\" + textEdit10.Text + "\\" + DateTime.Now.Year + "\\DATABASE.FDB" + ";data source=localhost;user id=SYSDBA;password=masterkey;server type=0"";
asd.ConnectionString = con;
configuration.AppSettings.CurrentConfiguration.ConnectionStrings.ConnectionStrings.Add(asd);
configuration.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");