Products

Solutions

Resources

Partners

Community

Blog

About

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 using X tables/dataprovidersmodule using X tables/dataproviders
Previous
 
Next
New Post
10/4/2006 10:52 AM
 
How can I make my module use 2 data providers, I don't fully understand the provider architecture in dnn, but I think each module can only have one dataprovider and one sqldataprovider.
 
So, the question is, how can I work with multiple tables from a single module?
 
New Post
10/4/2006 3:06 PM
 

Why not just make your dataprovider & sqldataprovider class handle multiple functions for different tables?

in your dataprovider, just add defined abstract methods for the different tables.  i.e.  Then plug the functionality into your controller and sqldataprovider to match.

 

Imports System

Imports System.Web.Caching

Imports System.Reflection

Namespace myCompany.DNN.Modules.myCompanyUtil.Data

Public MustInherit Class DataProvider

#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("data", "myCompany.DNN.Modules.myCompanyUtil.Data", "myCompany.DNN.Modules.myCompanyUtil"), DataProvider)

End Sub

' return the provider

Public Shared Shadows Function Instance() As DataProvider

Return objProvider

End Function

#End Region

#Region "Abstract Methods"

'---------------------------------------------------------------------

' TODO Declare DAL methods. Should be implemented in each DAL DataProvider

' Use CodeSmith templates to generate this code

'---------------------------------------------------------------------

Public MustOverride Function ListTable1() As IDataReader

Public MustOverride Function ListTable2() As IDataReader

Public MustOverride Function ListTable3() As IDataReader

Public MustOverride Function InsertTable1() As Integer

Public MustOverride Function InsertTable2() As Integer

Public MustOverride Function InsertTable3() As Integer

Public MustOverride Function UpdateTable1() As Integer

Public MustOverride Function UpdateTable2() As Integer

Public MustOverride Function UpdateTable3() As Integer

#End Region

End Class

End Namespace

Hope that helps!

Wallew

 
New Post
10/5/2006 3:45 AM
 

I'm a bit confused, so in the createprovider method:

objProvider = CType(Reflection.CreateObject("data", "YourCompany.Modules.GuestBook", ""), DataProvider)

 "YourCompany.Modules.GuestBook" is not really the name of the database table but the name of the class? I don't understand reflection.

If I understand, if I create the stored procedures, and add the methods to call the procedures in the dataprovider and the sqldataprovider I should be able to work with as many tables as I want, right?

 

 
New Post
10/5/2006 11:28 AM
 

You are correct, YourCompany.Modules.GuestBook is your class, not the table.  Ultimately, the SQLDataProvider is just executing a stored procedure.  If you write your stored proc to access multiple tables, your module will use multiple tables.

For Example:

If you have a stored proc named GetUserRoles and does something like

SELECT
  'portalname' = p.portalname,
  'portalid' = p.portalid,
  'rolename' = r.rolename
FROM userroles U
JOIN roles R ON r.roleid = u.roleid
JOIN portals P ON p.portalid = r.portalid
WHERE u.userid = @UserID


Then you have a function in your SqlDataProvider like

Public Overrides Function GetUserRoles(ByVal UserID As Integer) As IDataReader
  Return CType(SqlHelper.ExecuteReader(ConnectionString, "GetUserRoles", UserID), IDataReader)
End Function


All that's happening is the sp you call in the SqlDataProvider executes. In this example, you are accessing data from tables userroles, roles and portals to return the portal name, portalid and role name for any given user. Basically, if you can write an sql statement to do what you want in Query Analyzer, you can turn that into a stored proc and call it from your SqlDataProvider. There is no need to worry about multiple dataproviders.

 
New Post
10/6/2006 3:28 AM
 
Thanks a lot, I think I finally understand it.
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0module using X tables/dataprovidersmodule using X tables/dataproviders


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