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

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Connecting your DotNetNuke® Module to another databaseConnecting your DotNetNuke® Module to another database
Previous
 
Next
New Post
5/16/2007 12:30 AM
 

ecktwo wrote

You can consider storing the connection string in the module setting.  This approach has many advantages:

 

This is also my recommendation.



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
5/16/2007 7:29 AM
 

Ecktwo and Michael, thank you for the advice. I'm still torn thou of having to update the connection string in every control in the module (moving from dev to prod). I DO understand the modules I'm creating don't require a significant amount of portability since they're specific to my needs. Perhaps I should just shutup and color and put the information in the module as suggested here and in the DAL+.

Module navigation is another story. :-(

<JP>

 
New Post
5/16/2007 8:02 AM
 

PaskettJ wrote

Module navigation is another story. :-(

You saw this?

Module Navigation Options



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
5/16/2007 8:33 AM
 

Actually, I don't recommend storing connection strings somewhere other than with all the other connection strings - in web.config.  I take the view that for maintenance purposes, it is much easier to manage similar resources in one common location, rather than search all over web.config and then search through modulesettings table, and then tabmodulesettings table and then maybe a custom module table.

So my approach would be to create a subclass of the DotNetNuke SqlDataProvider class and then to create a simple factory class that knew how to create my custom SqlDataProvider. 

The factory class would essentially be a clone of the standard Shared methods in the regular DotNetNuke DataProvider class without all of the abstract methods.  This would give me the caching and performance benefits of using statics/shared method along with the caching afforded by the createobject method:

Public Class MyDataProviderFactory

#Region "Shared/Static Methods"

' singleton reference to the instantiated object
Private Shared objProvider As DataProvider = Nothing

' constructor
Shared Sub New()
    CreateProvider()
End Sub

' dynamically create provider
Private Shared Sub CreateProvider()
    objProvider = CType(Framework.Reflection.CreateObject("MyNamespace.MySqldataprovider, MySqlDataProvider", "MySqlDataProviderCacheKey"), DataProvider)
End Sub

' return the provider
Public Shared Shadows Function Instance() As DataProvider
    Return objProvider
End Function

#End Region

End Class

At this point I could now create my own custom SqlDataProvider class that inherited from the standard DNN SqlDataProvider class and overrode the connection string property.

ImportsDotNetNuke.Common.Utilities
Imports DotNetNuke.Data

MyNamespace
    Public Class MySqlDataProvider
        Inherits SqlDataProvider

        Private _connectionString As String

        Public Sub New()
            MyBase.New()
            _connectionString = Config.GetConnectionString("NameOfMyConnectionString")
        End Sub

        Public Overloads ReadOnly Property ConnectionString() As String
            Get
                Return _connectionString
            End Get
        End Property

    End Class
End
Namespace

So the reason for doing this is now in my code I can use a similar method for all of the my data access: 
To execute SQL against the default DNN database:

    DataProvider.Instance().ExecuteSQL("Select * from MyTableInDNN")

To execute SQL against the alternate database defined by my custom connection string:

    MyDataProviderFactory.Instance().ExecuteSQL("Select * from MyTableInAccountingSystem")

Since most systems will have several developers working on them over their lifetime, it is always best to stick with known development patterns whenever possible.  In this case a new developer looking at your code would not be surprised by some new mechanism for accessing the secondary database.  It would be using the same structure as the standard DNN methods and thus should greatly ease maintenance burdens.


Joe Brinkman
DNN Corp.
 
New Post
5/16/2007 9:23 AM
 

OMG - How do i learn to develope DNN modules, for use with other databases, link anyone.  I was given a sizeable project about a year ago to build a data-store of over 3,000,000 products.   After learning that mosting DNN hosting packages drop at 200mb for the SQL i was scrating my head for weeks.  Then decided i would static all the pages as aspx.  If you can imagine, creating over 3,270,000 pages to store, and catagorize all these products.


OMG - How do i learn to develope DNN modules, for use with other databases, link anyone. 


Shawn E Carter www.ShawnsSpace.com
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Connecting your DotNetNuke® Module to another databaseConnecting your DotNetNuke® Module to another 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