سلام برنامه تحت شبکه نوشتم که درست می کرد ولی یک دفعه با پیغام زیر مواجه شدم(تمام تنظیمات لازم رو انجام داد و کل اینترنت رو هم جستجو کردم و تظیمات که گفته بودن رو انجام دادم ولی درست نشد)
مشکل کجاس
فقط
1- از app.config اسنفاده کردم و اینهم کدش
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<coectionStrings>
<add name="namecoection"
coectionString="Data Source=(local);Initial Catalog=Database_Data;User ID=sa;Password=09181736740"
providerName="System.Data.sqlclient" />
</coectionStrings>
</configuration>
و وقتی هم برنامه شروع میشه در صورتی که ای پی سرو ر تغییر می توان وارد کرد که اینم کدش هست
string Coection = "";
if (radioButton2.Checked)
{
Coection = string.Format("Data Source={0},1433;Initial Catalog={1};User ID={2};Password={3}", textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text);}
else
{
Coection = "Data Source=.;Initial Catalog=Database_Data;User ID=sa;Password=09181736740";
}CheckingSource(Coection);
new fr_mhart().ShowDialog();
private void CheckingSource(string constr)
{var config = ConfigurationManager.OpenExeConfiguration(Applicat ion.StartupPath + @"information.exe");
config.CoectionStrings.CoectionStrings["namecoection"].CoectionString = constr; //CONCATINATE YOUR FIELDS TOGETHER HERE
config.Save(ConfigurationSaveMode.Modified, true);
ConfigurationManager.RefreshSection("coectionStr ings");
}
- - , .
برچسب:
نویسنده: محمد رضا جوادیان