May 19, 2012 at 3:25 PM
Edited May 20, 2012 at 2:45 PM
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:
connectionString="Data Source=TONE-PC-WIN;Initial Catalog=BlahDB;Persist Security Info=True;User ID=useridblah;Password=passwordblah"
and this code to get the connection string value:
System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/ModuleName");
if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0)
connString = rootWebConfig.ConnectionStrings.ConnectionStrings["BlahConnectionString"];
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?