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.0Problem using custom Data ProviderProblem using custom Data Provider
Previous
 
Next
New Post
5/28/2008 6:06 AM
Accepted Answer 

OK, after considerable head-butting & hair-pulling, I have got it through.

The problem is that the SqlDataProvider in DNN (for worse) has special treatment. The culprit is the following code in abstract DataProvider:

        Private Const ProviderType As String = "data"    ' maps to <sectionGroup> in web.config
        Private Const ProviderNamespace As String = "DotNetNuke.Data"    ' project namespace
        Private Const ProviderAssemblyName As String = ""    ' project assemblyname

        ' 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(ProviderType, ProviderNamespace, ProviderAssemblyName), DataProvider)
        End Sub

You can clearly see the hard-coded Provider NameSpace (although the assembly name is not hard-coded). So, DNN expects its concrete DataProvider to be always DotNetNuke.Data.SqlDataProvider. (For some strange reasons beyond comprehension, the Provider namespace is not discovered the same way i.e. Reflection, as it is done for other providers).

This affectively means that you can put your DataProvider in any assembly as you wish (remember, it should still inherit the abstract provider), but the Fully Qualified Name of the DataProvider should always be DotNetNuke.Data.SqlDataProvider.

What's more, when you put this assembly in the bin folder, there arises another problem. Now there are two classes with exactly same Fully Qualified Name, that is unacceptable to DotNet. That effectively means that you need to delete the DotNetNuke.SqlDataProvider.dll assembly from your bin folder. Although you can change the abstract Data Provider to find the concrete Provider namespace y Relfection easily (just copy the code from any other provider to do so), but this code is at the heart of DNN, and modifying it would render your installation utterly difficult to upgrade. So, deleting the DNN Core provider is the prefered way according to me.

Lastly, I wanted to customize only 10-12 method. So, I inherited the DNN SqlDataProvider. But with this came the same situation again. Although I had deleted the DNN's SqlProvider assembly from the bin, but my custom provider referenced it as it inherited from one of its classes. In effect, referencing my assembly in DNN copied the DNN's provider again into the bin folder, again creating namespace conflicts.

I seriously wanted to avoid rewriting all SqlProvider methods. SO, now what I have done is to copy the DNN SqlDataProvider's source class to my custom Provider assembly, renamed it to DNNSqlDataProvider, and then inherited it. I know this is a not a clean solution, but it provided me 2 advantages: I did not had to recode the entire Provider, and 2) While upgrading for a future version of DNN, I can just copy-paste the new DNN SqlDataProvider again, it there is any change to it, inherit it & see which methods need to be overridden.

Finally, the web.config part, it should look like following:

    <data defaultProvider="SqlDataProvider">
        <providers>
            <clear/>
            <add name="DNNSqlDataProvider" type="DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider" connectionStringName="SiteSqlServer" upgradeConnectionString="" providerPath="~\Providers\DataProviders\SqlDataProvider\" objectQualifier="" databaseOwner="dbo"/>
            <add name="SqlDataProvider" type="DotNetNuke.Data.SqlDataProvider, Imbibe.DNN.Provider.SharedProfile" connectionStringName="SiteSqlServer" upgradeConnectionString="" providerPath="~\bin\" objectQualifier="" databaseOwner="dbo"
                          sharePersonalizationInfo="true" />
        </providers>
    </data>
Although you can delete the entry for DNN's Sql DataProvider, I kept it just for reference. REMEMBER, the name of the default DataProvider should remain SqlDataProvider, as has been explained on this thread:

http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/111/threadid/171688/scope/posts/Default.aspx

Rename DNN's Provider or delete it, but keep the default provider's name to be SqlDataProvider. What's more, in the type attribute, the name of the Provider is inconsequential (I haven't tried with assembly name, but believe that invalid assembly name should should lead to a run-time exception). But you can type any garbage value as the Fully Qualified Name of the Provider class in the type attribute, and DNN would ignore it, as the this has already been hard-coded into DNN as shown above!!!

Hope, this would help many others!!!

 
New Post
5/29/2008 11:11 PM
 

r_honey - I have to do some digging around but I'm pretty sure you don't need to leave the default dataprovider as SqlDataProvider. I am the author of the Oracle dataprovider and I know for a fact that the default provider for oracle is named OracleDataProvider and not SqlDataProvider. I took a look at the other thread you mentioned and the user is partially correct. If you're using the SqlDataProvider, DNN does default it to xxx.sqldataprovider but this is because it has to have a way of identifying what dataprovider to use. I do know that I have installations running on Oracle which have the sqldataprovider.dll files (for the core as well as modules) in the bin folder and dnn does not have any problem loading the right dlls...

I think what the other person was trying to do (and the same goes to u) is to use the sqldataprovider provided by the core but override some of the specific functions/stored procedure calls. In this case short of creating a custom version of the dataprovider with your own implementation of the overridable calls, I don't see how you'd expect this to work in any case...

Sanjay


AcuitiDP - Oracle Data Provider for DotNetNuke
 
New Post
5/30/2008 1:10 AM
 

Sanjay wrote

I'm pretty sure you don't need to leave the default dataprovider as SqlDataProvider. I am the author of the Oracle dataprovider and I know for a fact that the default provider for oracle is named OracleDataProvider and not SqlDataProvider.

In that case, I guess the Provider name has to be SqlDataProvider, OracleDataProvider or anything like that, which exactly matches "DBMS name" + "DataProvider".

Sanjay wrote

DNN does default it to xxx.sqldataprovider but this is because it has to have a way of identifying what dataprovider to use. I do know that I have installations running on Oracle which have the sqldataprovider.dll files (for the core as well as modules) in the bin folder and dnn does not have any problem loading the right dlls...

As you can see from the abstract DataProvider code shown above from DNN code, DNN expects the DataProvider to be from DotNetNuke.Data namespace. Now, if I want to provide my own Provider for SqlServer, it needs to be named SqlDataProvider. Next, it needs to be in DotNetNuke.Data namepsace. As soon as I do that & deploy my assembly to bin, it creates namespace collisions. So, there is no choice but to delete DotNetNuke.SqlDataProvider.dll

In your case, I guess it is working becuase your Provider's Fully Qualified name is, DotNetNuke.Data.OracleDataProvider. As your class name is different coz you are using Oracle, it does not cause collisions. But anytime, you provide Provider for SqlServer, it would cause collision because of specific name requiremetns. That automatically means, I cannot have my own SqlDataProvider that inheruts from DNN SqlDataProvider, coz both would be classes with same name in same namespace.

Now, I see one more reason to use the name SqlDataProvider. Modules use reflection to create their provider instance. And their provider name has to match the main provider name being used, i.e. SqlDataProvider if Sql Server is the backend. That effectively means, that the Provider name has to be the DBMS name followed by the "DataProvider" suffix.

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Problem using custom Data ProviderProblem using custom Data Provider


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