Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

telerik -- supercharge your DNN websites
  Ads  
Active Modules -- Active Forums for DotNetNuke
 


  Sponsors  

Meet Our Sponsors

Webhost4life, specialists in DNN hosting
Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
SteadyRain
DataSprings - Great Ideas. Always Flowing.
R2integrated - formerly bi4ce
Jango Studios - Skins, Modules and Hosting for DotNetNuke
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  working with multiple databases
Previous Previous
 
Next Next
New Post 4/4/2007 8:58 AM
User is offline Hal Hayes
4 posts
10th Ranked


working with multiple databases 

Besides the DNN database, I need to create a module that connects to a different database to pull information for display.

Can I create an additional connection string in the web.config that can be called for the module to connect?

If so, can I and how do I us the DNN infrastructure to make the call to the other database from within the module (as opposed to writing straight ADO.NET code)?

Thanks,

Hal

 
New Post 4/4/2007 9:48 AM
User is offline Chris Hammond
2951 posts
www.engagesoftware.com
5th Ranked








Re: working with multiple databases 

I think you'd be better off doing straight ado.net code to call your other database as DNN is pretty much setup to pull information from the default dataprovider, and you're basically looking to call a different provider.

Perhaps someone else will have a better suggestion, but that is how I would start


Chris Hammond
Engage Software
St. Louis, MO
314.966.4000


The leading provider of DotNetNuke skinning, training and custom module development.
Official DotNetNuke® Training Provider
 
New Post 4/4/2007 10:45 AM
User is offline ech01
631 posts
7th Ranked




Re: working with multiple databases 
Modified By ech01  on 4/4/2007 12:47:08 PM)

Yes, you can specify it in the webconfig and in the dataprovider and sqldataprovider, make sure you change it to point to the new configuration.

Below I changed the default "Data" to point to a new config called "applicationData"

SqlDataProvider File
Private Const ProviderType As String = "applicationData"

DataProvider File
' dynamically create provider
Private Shared Sub CreateProvider()
objProvider = CType(Framework.Reflection.CreateObject("applicationData", "NamespaceGoesHere", ""), DataProvider)
End Sub

WebConfig File
<sectionGroup name="dotnetnuke">
<section name="data" requirePermission="false" type="DotNetNuke.Framework.Providers.ProviderConfigurationHandler, DotNetNuke"/>
<section name="applicationData" requirePermission="false" type="DotNetNuke.Framework.Providers.ProviderConfigurationHandler, DotNetNuke"/>

...

<connectionStrings>
<add name="SiteSqlServer" connectionString="..." providerName="System.Data.SqlClient"/>
<!-- Connection String for SQL Server 2000/2005 -->
<add name="applicationData" connectionString="New Connection String Goes Here" providerName="System.Data.SqlClient"/>

...

<appSettings>
<!-- Connection String for SQL Server 2005 Express - kept for backwards compatability - legacy modules -->
<add key="SiteSqlServer" value="..."/>
<!-- Connection String for SQL Server 2000/2005 - kept for backwards compatability - legacy modules-->
<add key="applicationData" value="New Connection String Goes Here"/>

...

<dotnetnuke>
<!--ApplicationDatabase Provider-->
<applicationData defaultProvider="SqlDataProvider">
<providers>
<clear/>
<add name="SqlDataProvider" type="DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider" connectionStringName="applicationData" upgradeConnectionString="" providerPath="~\Providers\DataProviders\SqlDataProvider\" objectQualifier="" databaseOwner="dbo"/>
</providers>
</applicationData>

...


www.blackhawksurfaces.com | www.nlsales.com | www.midwestfilmandvideo.com
 
New Post 4/4/2007 11:33 AM
User is offline Carlos Rodriguez
526 posts
www.almacigo.com
8th Ranked


Re: working with multiple databases 

Another option I've been playing with lately and seems to work nicely is the new data objects in ADO.Net 2.0, available obviously with ASP.Net 2.0 and Visual Studio 2005.  Note that if you are dealing with new tables, even in the DNN's own database, there is not much of a "DNN Infrastructure" to help you, as far as DAL components.  You would have to create it.  For that reason is that you need to consider the two approaches below.  To be honest, for my modules I have not created the full DAL architecture for data access but I do try to use Stored Procs for all data access.

Anyway, after adding the new connection string to the Web.config, you can go to VS2005 and create a "SQLDataSource" that other controls on the page can use.  You just define the connection string like this:

"<%$ ConnectionStrings:SiteSqlServer %>" for the default connection, or "<%$ ConnectionStrings:YourNewString %>" for a new string to a second database. 

All the power of ADO.Net 2.0 and its integration with VS 2005 is now at your hands and you can use all those articles you read about in various ASP.Net sites.  This is what I like the most, data access becomes "standardized" and I now have more resources at my disposal.  I started testing this with a GridView and it can do paging and sorting with no code in a DNN module, really amazing.  And let me tell you that I was skeptical at the beginning as I like to code all the data access by hand and not use the graphical interface to do it.  The implementation in ADO.Net 2.0 and VS 2005 is a lot cleaner than what it was in 1.1.

Bear in mind that all the nice features work by default with Datasets, if you want to optimize and use Datareaders then you would have to do coding by hand.  This may or may not be an issue for your site/app.

You can always do data access with the DAL+ as described by Michael Washington here: http://www.adefwebserver.com/DotNetNukeHELP.

Carlos

 

 
New Post 4/4/2007 2:27 PM
User is offline Craig Walker
238 posts
9th Ranked


Re: working with multiple databases 

Is the other database you want to connect to in the same sql server instance?  If so, you can use straight sql syntax to explicitly call the desired database.

In your stored proc, just reference the other database.  This assumes the other data you need is on the same server as your dnn database, but it does not need to be the same database.  Something like this...

SELECT
    'username' = u.username,
    'firstname' = u.firstname,
    'lastname' = u.lastname,
    'hiredate' = e.hiredate,
    'department' = e.department,
    'jobcode' = j.jobcode
FROM dotnetnuke.dbo.users U
JOIN companydb.dbo.employees E ON e.employeeid = u.username
JOIN hrdb.dbo.jobcodes J ON j.employeeid = e.employeeid
WHERE u.username = @username

 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  working with multiple databases
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Jetkey Smart Map
Smart Map is an AJAX powered Google Map module that displays driving directions, proximity search results and data from your own databases. Smart Map reads GPX (GPS data) files, GeoRSS feeds, and KML data. You can pass any querystring parameter to Smart Map and into your own custom queries to control what data displays on the map.
smartmap.jetkey.com
DNNSpired.com
Inspired to extend DotNetNuke®, everyday.
www.DNNSpired.com
TMA Resources
TMA Resources is a software company providing eBusiness solutions for the Association market.
www.tmaresources.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP