Chaning DataBase connection at runtime
Posted: Tue 29 May 2012 20:40
I can easily use LinqConnect at Design time to set a fixed connection string. But some of our users will need to change the port and login information at runtime.
This is no problem with ADO connections (see below) but how does one do this with LinqConnect where the only handle on has is the context that one created from the model
DBmodel context = new namespace.DBmodel();
ADO version:
This is no problem with ADO connections (see below) but how does one do this with LinqConnect where the only handle on has is the context that one created from the model
DBmodel context = new namespace.DBmodel();
ADO version:
Code: Select all
Devart.Common.DbConnectionStringBuilder csb = new Devart.Common.DbConnectionStringBuilder();
csb["Host"] = "localhost";
csb["Port"] = 5432;
csb["User Id"] = "postgres";
csb["Password"] = "*******";
csb["Database"] = "GPL";
csb["Max Pool Size"] = 150;
csb["Connection Timeout"] = 30;
PgSqlConnection conn = new PgSqlConnection(csb.ConnectionString);