May 19, 2012 at 2:25 PM
Edited May 20, 2012 at 1:45 PM
|
Update 2012-05-20:
I am using the same SQLExpress database for Orchard content as well as my module, which is an existing website that I am migrating into Orchard as a module. The existing site has its own tables/stored procs.
*******
I need to store a connectionstring in the web.config of my module as I am connecting to a separate database from the rest of Orchard. I have my db connection working fine. I have this in my module's web.config:
<connectionStrings>
<add name="BlahConnectionString"
connectionString="Data Source=TONE-PC-WIN;Initial Catalog=BlahDB;Persist Security Info=True;User ID=useridblah;Password=passwordblah"
providerName="System.Data.SqlClient" />
</connectionStrings>
and this code to get the connection string value:
System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/ModuleName");
System.Configuration.ConnectionStringSettings connString;
if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0)
{
connString = rootWebConfig.ConnectionStrings.ConnectionStrings["BlahConnectionString"];
return connString.ConnectionString;
}
but it returns null. If I look for it by index there is only one connectionstring returned (at 0 index) and it is for the main Orchard site.
What am I missing here?
|