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 ...Combining from 2 different database tables displayed on DNN siteCombining from 2 different database tables displayed on DNN site
Previous
 
Next
New Post
9/14/2009 5:37 PM
 

Hi I am not sure if this is the correct forum to be asking this in. But I am using VS2008 and am using a DNN module to pull information based on a specific Article on our website. On the home page I am trying to display the Title, Summary, Date and Author of the article. Currently under our feature Stories section of the site http://prepsonthenet.com/dnn/Home/tabid/386/Default.aspx the Title, Summary and Date are the only things displayed.

In our database we have an Article table that has the Title, Summary and Date listed where the data is pulled from to be displayed which makes sense. I am now currently trying to pull the Author Name to go along with this. However the 'Author' Name needs to be pulled from the Author table. There is a field in this Author DB table for the Author name but when I try to grab that the DNN module just crashes. I have gone into the App_Code folder and added a private string _Name;

I am thinking this could possibly just be a simple JOIN function or something along those lines that links up the AuthorID in both tables (Article and Author) to then display the Name. I posted this on another forum and got some good responses but someone thought a join function may be different when using DotNetNuke? http://forums.asp.net/p/1465896/3404512.aspx#3404512

Old code that works but doesn't grab the 'Author' name:
strQueryArticleFirst.Append("select top 4 ArticleID,Title,Summary,[Text],");   
strQueryArticleFirst.Append("Convert(varchar(50),date,110)as [Date] from article");  
strQueryArticleFirst.Append(" where CategoryID=27 AND State='WI' and deleted is null ");         

        

New code that crashes the DNN Module when trying to grab the 'Author' name:
 

 
strQueryArticleFirst.Append("select top 4 ArticleID,Title,Summary,[Text],Article.Name,");  
strQueryArticleFirst.Append("Convert(varchar(50),date,110)as [Date] from article");      
strQueryArticleFirst.Append("INNER JOIN Author ON Article.AuthorID = Author.AuthorID");    
strQueryArticleFirst.Append(" where CategoryID=27 AND State='WI' and deleted is null ");           

 

A similar join on a different page that works right now. Would it be similar to something like this?

stringBuilder strArticle = new StringBuilder();   
strArticle.Append("SELECT *,");   
strArticle.Append(" (SELECT NAME FROM AUTHOR AU WHERE AU.AUTHORID = AR.AUTHORID) AS AUTHORNAME,");  
strArticle.Append(" (SELECT EMAIL FROM AUTHOR AU WHERE AU.AUTHORID = AR.AUTHORID) AS AUTHOREMAIL,");   
strArticle.Append(" (SELECT PICTURE FROM AUTHOR AU WHERE AU.AUTHORID = AR.AUTHORID)AS AUTHORPIC");   
strArticle.Append" FROM ARTICLE AR WHERE (AR.DELETED <> 1 OR AR.DELETED IS NULL) AND AR.ARTICLEID='" + strArticleId + "'");//1911,1728,363,873  

 

 

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Combining from 2 different database tables displayed on DNN siteCombining from 2 different database tables displayed on DNN site


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