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 ...DNN database and custom modulesDNN database and custom modules
Previous
 
Next
New Post
2/2/2012 11:58 AM
 
Hi,

I am taking my first steps in DotNetNuke. My question must be very basic.

I easily set up a portal. Now I am trying to create a module that does some custom actions, such as querying a table in the DB.

 During the installation process, I created a DotNetNuke database which contains tables such as Portals, PortalSettings, Skins,  Profile, Users, etc. Also, when I afterwards created a module, a table named [my company name]_[module name] was created, along with a few stored procedures with names like [my company name]_Add / Delete / Get / Update [module name].

The problem is the data I want to query is not in that DotNetNuke (let's call it "DB_DNN") database but in another SQL Server DB (it will be "DB_other" for us), in the same server, that holds the tables for the company's employees data.

Do I need to replicate or link all of the data in DB_other to DB_DNN to be able to access it from NukeDotNetNuke? Can't I connect somehow to the source DB?

Thanks in advance,

Dani
 
New Post
2/2/2012 6:35 PM
 
Typically it's easiest to simply supply a different connection string to your module that points to the other database, though if you need to JOIN to elements within your dotnetnuke database then linked server queries are an option - http://www.techrepublic.com/blog/datacenter/how-do-i-query-foreign-data-using-sql-servers-linked-servers/133 or http://stackoverflow.com/questions/4091960/sql-server-linked-server-example-query cover this.

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
2/3/2012 2:32 AM
 
Thanks, Cathal,

That is exactly what i am after, I would like to use an additional connection string.

Maybe I am not understanding how it all works. As I understand it, my module makes use of five stored procedures to work with data in the database. I have a DataProvider abstract class that defines several methods to deal with DB data. These are overriden in its derivated class called SqlDataProvider. In the constructor of SqlDataProvider, we can find the following lines of code:

            //Get Connection string from web.config
            _connectionString = Config.GetConnectionString();

            if (_connectionString == "")
            {
                // Use connection string specified in provider
                _connectionString = objProvider.Attributes["connectionString"];
            }

When it does
    _connectionString = Config.GetConnectionString();
Is it looking for a connection string in web.config? In that case, if we have several connections strings defined, how can we specify which of them to use?

If it doesn't find one,

    if (_connectionString == "")

Where are provider connection strings defined?
    _connectionString = objProvider.Attributes["connectionString"];

Is it here where I should specify a different connection string depending o which data I am using? Can I set a connection string pointing to my employees DB and still be able to work with my DotNetNuke DB?

Thanks ins advance,

Dani
 
New Post
2/3/2012 2:39 AM
 

Hi,

I have another important question about working with a second DB, the one with employees data: do I need to create  the [my company]_add/delete/Get/Update[module name] stored procedures in the second DB as well?

Thank you,

 Dani

 
New Post
2/3/2012 4:47 AM
 
Dani, it depends on how you want to access your data - you may either use stored procedures or Linq2Sql, but you should avoid creating SQL queries from text dynamically passing to the database, due to the high risk of SQL injection.

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...DNN database and custom modulesDNN database and custom modules


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