How to take database info while creating dll [Resolved]

Posted by Amritha444 under C# on 3/9/2012 | Points: 10 | Views : 1046 | Status : [Member] | Replies : 1
Hi all

Im creating dll for each screens in my project .I have a class which contains all database operations. when creating dll for this class im giving database info like this

string strconnection = "Data Source=CLIENT01;Initial Catalog=dbname;User ID=sa;Password=pawd.;";
iam referencing this dll in number of places
but when iam changing the connection info i have to again refer this dll in every where in my project as it is a common dll.
Is there any other methods giving database info in my project so that database class dll refer this location(like appconfig)
how to take value of database info while creating database class dll

Thanks in Advance


Posted by: Hmanjarawala on: 3/9/2012 [Member] Bronze | Points: 50


Hi Amritha....
As you knwo config files contain key-value pair in XML representation.

you can do one thing, fix or hard-cord key name which contains connection string value. i.e.

in your Database class whenever you want connection string.
write Statement

string constr = ConfigurationManager.ConnectionStrings["dbConnection"].ConnectionString;

key-name dbConnection is fixed, but you can set different value for this key in your various projects.

hope this is what you want...

Mark this as answer, if it helps you.....

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response