I am trying to make some simple libraries that require database access. What I don't get is how to pass the connection string to the library... Right now I have a db.config in my dll, but I'm not sure how to reference it from within the dll etc...
This is how I have setup the libraries
[Solution File]
<configuration>
<!-- Connection string -->
</configuration>
Real simple:
1) If this happens to be a .Net .dll, you can store it in "app.config" or "web.config":
Example:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="DigiBrd"
connectionString="server=localhost;user id=****;Password=****;database=DigiBrd"
providerName="MySql.Data.MySqlClient" />
</connectionStrings>
</configuration>
String cnString =
ConfigurationManager.ConnectionStrings["DigiBrd"].ConnectionString;
2) You can also store the connection string anywhere that the .dll can read it. For example, you can use an .ini file or the registry.
3) You can implement a getConnectionString() method in your .dll.
4) Etc. etc. etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With