View Full Version : تغییر کانکشن برنامه در حال اجرا در Linq
saeid69
جمعه 11 دی 1388, 17:36 عصر
با سلام
یه برنامه با LINQ نوشتم که می خوام تحت شبکه کار کنه.
بنابراین کاربر باید امکان تغییر کانکشن در حین اجرای برنامه را داشته باشد.
با توجه به اینکه در propertis ==> seting امکان تغییر وجود ندارد و scop آن Application هست.
آیا کسی میتونه به من کمک کنه تا بتونم این کانکشن رو در linq عوض کنم؟
Ali_Mor
شنبه 12 دی 1388, 12:27 عصر
به سازنده های کلاس DataContext دقت کن، بعضی از آنها کانکشن استرینگ رو بعنوان ورودی می گیرند.
saeid69
یک شنبه 13 دی 1388, 18:50 عصر
آیا روش منطقی وجود نداره؟
یعنی مایکروسافت این امکان رو از لینک گرفته؟
خواهش میکنم هرکی میدونه زود جواب بده.
Ali_Mor
دوشنبه 14 دی 1388, 12:44 عصر
روش منطقی چیه که با اون روش اشاره شده نمی شه انجام داد!!؟؟
saeid69
دوشنبه 14 دی 1388, 15:49 عصر
یعنی اینکه آیا روشی وجود دارد که بتونیم با برنامه نویسی کانکشنو عوض کنیم؟
hdv212
پنج شنبه 17 دی 1388, 00:19 صبح
لطفا اینو تست کن :
//opening the config file
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None);
//ConnectionStringsSection object
System.Configuration.ConnectionStringsSection connstrsectn = config.ConnectionStrings;
//modifying the provider name
connstrsectn.ConnectionStrings["MyAssemblyNameSpace.Properties.Settings.NorthwindC onnectionString"].ConnectionString = "sssssssssssssssssssssssssssssss";
/* save changes
* Note: you will see these changes in the appconfig file in your bin folder (in the form of [exename].config)
* and NOT in your project file app.config
*/
config.Save();
Properties.Settings.Default.Upgrade();
this.textBox2.Text = Properties.Settings.Default.NorthwindConnectionStr ing;
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.