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.0Module That Points to a Different DatabaseModule That Points to a Different Database
Previous
 
Next
New Post
1/25/2007 7:27 PM
 
I have created a custom module based on the samples mentioned in the forum. Everything works except I need my custom modules to read from and write to a database that is different from the database where my DNN install is.

For example, my SiteSqlServer connection string (the one that my DNN installation uses) =  "Server=(local);Database=DNN;Integrated Security=True;" , but my modules have to read to and write from another database (let's call it "custom") on the same server.

How can I do this?
 
New Post
1/25/2007 10:03 PM
 

see:

Connecting to another database

string ConnectionString = "Server=(local);Database=Northwind;uid=MyUserName;pwd=MyPassword;";
StringBuilder mySqlString = new StringBuilder();

mySqlString.Append("SELECT * ");
mySqlString.Append("FROM Customers ");

GridView1.DataSource = SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, mySqlString.ToString()));

GridView1.DataBind();
     



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
1/26/2007 11:12 AM
 

Actually, I was looking for a way to do it without hard-coding the connection strings, and - thanks to a night of insomnia - I figured it out:

(1) In your SqlDataProvider.vb module's constructor, change "_providerConfiguration.DefaultProvider" to, for example "custom":


'Dim objProvider As Framework.Providers.Provider = CType(_providerConfiguration.Providers(_providerConfiguration.DefaultProvider), Framework.Providers.Provider)

Dim objProvider As Framework.Providers.Provider = CType(_providerConfiguration.Providers("custom"), Framework.Providers.Provider)

(2) In web.config, add another provider (called "custom") to the DotNetNuke\data config section:

<data defaultProvider="SqlDataProvider">

      <providers>
            <clear/>

            <add name="SqlDataProvider" type="DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider" connectionStringName="SiteSqlServer" upgradeConnectionString="" providerPath="~\Providers\DataProviders\SqlDataProvider\" objectQualifier="" databaseOwner="dbo"/>

            <add name="custom"
type="DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider"
connectionString="Data Source=servername;Database=databasename;Integrated Security=True" 
upgradeConnectionString="" providerPath="~\Providers\DataProviders\SqlDataProvider\"
objectQualifier=""
databaseOwner="dbo"/>
      </providers>

</data>

You can also use connectionStringName="customConnectionString" instead of connectionString="...", but you’ll have to add a connection string to the <appSettings> section of web.config:

 
<appSettings>
<add name="customConnectionString"

      connectionString="Server=servername;Database=databasename;Integrated Security=True;"

providerName="System.Data.SqlClient"/>
</appSettings>
 
New Post
2/1/2007 1:20 AM
 
One way I have found of doing this is via web services.

For a previous project I'd already written a basic DAL DLL based on the Microsoft Enterprise Library Data Access Block. By the look of the method names in DNNs DAL it looks like they are doing the same thing. I then call the DLL from the web services to execute the requested database stored procedure (we don't allow in-line SQL script). This is all configurable via the web service configuration file.

I'm new to DNN but so far I've used this method to retrieve data from multiple databases in one module without having to re-code providers or change the web.config file (other than adding the web service references).

An added bonus of doing this is that the web service can impersonate a service account that is different to that running the front end web site. This adds another layer of security for the hackers to get through.

Regards
Scott
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Module That Points to a Different DatabaseModule That Points to a Different Database


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