Hi friends,
I'm new in C# and MVC. I'm using nop V2.3 and try to write a new plugin. I must connect the database and make some changes.
When i write connectionstring by manually in my plugin, it is work. But this method is not usefull for all person's usage.
I try these things:
1
Nop.Core.Data.DataSettings dbsttngs = default(Nop.Core.Data.DataSettings);
SqlConnection sqlConnection1 = new SqlConnection(dbsttngs.DataConnectionString.ToString());
.
.
.
//did not work. Or i made some mistakes.
2
StreamReader re = File.OpenText("~/App_Data/Settings.txt");
string input="";
string constring = "";
string a = "";
while ((input = re.ReadLine()) != null)
{
if (input.Contains("DataConnectionString")) {
a = input;
a = a.Replace("DataConnectionString: ", "");
a = a.Replace("DataConnectionString:", "");
constring = a;
}
}
re.Close();
SqlConnection sqlConnection1 = new SqlConnection(constring);
.
.
.
//did not work because program couldn't find settings.txt file
Please help me how can i get connectionstring in V2.3? Sorry for my bad English.