Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to create 2x ConnectionStrings ????How to create 2x ConnectionStrings ????
Previous
 
Next
New Post
11/12/2007 12:43 PM
 

Hello,

i wanted to ask if somebody can give me a small guide on how to create 2 ConnectionStrings. Must i only edit the web.config or must i also edit something in the constructor of the sqldataprovider class ???

 

 
New Post
11/12/2007 12:51 PM
 

You can add another string to the web.config file without issue, the key will be modifying your module to use that string versus the default connection string. You can modify your provider class in your module to do so.


Chris Hammond
Former DNN Corp Employee, MVP, Core Team Member, Trustee
Christoc.com Software Solutions DotNetNuke Module Development, Upgrades and consulting.
dnnCHAT.com a chat room for DotNetNuke discussions
 
New Post
11/12/2007 2:02 PM
 

all i changed in my web.config was:

<add name="SiteSqlServer"
       connectionString="Server=MYCOMPUTER\SQLEXPRESS;   Database=MYDBone;   uid=MYUSERone;   pwd=MYPWone;"
      providerName="System.Data.SqlClient"/>
   
    <add name="SiteSqlServer2"
       connectionString="Server=MYCOMPUTER\SQLEXPRESS;   Database=MYDBtwo;   uid=MYUSERtwo;   pwd=MYPWtwo;"
      providerName="System.Data.SqlClient"/>

and

<add key="SiteSqlServer" value="Server=MYCOMPUTER\SQLEXPRESS;    Database=MYDBone;   uid=MYUSERone;   pwd=MYPWone;"/>
    <add key="SiteSqlServer2" value="Server=MYCOMPUTER\SQLEXPRESS;    Database=MYDBtwo;   uid=MYUSERtwo;   pwd=MYPWtwo;"/>

how exactly can i get now the 2nd connection string in my CODE

my function is f.e.

 Public Overrides Function EplanShowAllBU() As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, "EPlanShowAllBU"), IDataReader)
        End Function

i have no clue how the strings from web.config come down to the code ...

 
New Post
11/12/2007 2:17 PM
 

Is it possible to do it like this:

 

<add name="SiteSqlServer"
       connectionString="Server=MYCOMPUTER\SQLEXPRESS;   Database=MYDBone;   uid=MYUSERone;   pwd=MYPWone; Server=MYCOMPUTER\SQLEXPRESS;   Database=MYDBtwo;   uid=MYUSERtwo;   pwd=MYPWtwo;"
      providerName="System.Data.SqlClient"/>

and then always when i call the connection string out of my SqlDataProvider to write

 

Public Overrides Function EplanShowAllBU() As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString.Startswith("
Server=MYCOMPUTER\SQLEXPRESS;   Database=MYDBtwo;"), "EPlanShowAllBU"), IDataReader)
        End Function

or ConnectionString.Endswith("uid=MYUSERone;   pwd=MYPWone;")

and so on ...

 

 

 
New Post
11/12/2007 3:47 PM
 

You should be able to do it that way, but you could also do it with

GetConnectionString(GetDefaultProvider("data").Attributes("connectionStringName"))

And supply the name of your second ConnectionString. If you open the source solution for DNN you can find the Library\components\Shared\.Config.VB file, in which DNN pulls the standard Connection string out.


Chris Hammond
Former DNN Corp Employee, MVP, Core Team Member, Trustee
Christoc.com Software Solutions DotNetNuke Module Development, Upgrades and consulting.
dnnCHAT.com a chat room for DotNetNuke discussions
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to create 2x ConnectionStrings ????How to create 2x ConnectionStrings ????


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out