Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Query Executes but doesn't function on website

Author  Topic 

potn1
Starting Member

33 Posts

Posted - 2009-10-06 : 13:49:20
Hi so I am executing a query in SQL Server management studio and I am able to pull the exact data I am looking for using this:

SELECT TITLE, ARTICLEID, VIDEOARCHIVED, SUMMARY, DATE, NAME,
SUBSTRING(TITLE,1,1) AS 'BREAK'
from preps.dbo.Article
INNER JOIN preps.dbo.Author ON Article.AuthorID = Author.AuthorID
WHERE (preps.dbo.Article.Deleted <> 1 OR preps.dbo.Article.Deleted IS NULL) AND (CATEGORYID IS NOT NULL OR CATEGORY2ID IS NOT NULL)


I then bring this over to our actual website in our ascx.cs file to run the query append and it just seems to crash:

strQuery.Append("SELECT TITLE, ARTICLEID, VIDEOARCHIVED, SUMMARY, DATE, NAME, ");
strQuery.Append("SUBSTRING(TITLE,1,1) AS 'BREAK'");
strQuery.Append(" from Article ");
strQuery.Append(" INNER JOIN Author ON Article.AuthorID = Author.AuthorID ");
strQuery.Append(" WHERE (Article.Deleted <> 1 OR Article.Deleted IS NULL) AND (Article.CATEGORYID IS NOT NULL OR Article.CATEGORY2ID IS NOT NULL)");


Does anyone have any idea where my issue would be coming from? Any help is appreciated. Thanks!

X002548
Not Just a Number

15586 Posts

Posted - 2009-10-06 : 13:58:35
why don't you use stored procedures?


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

potn1
Starting Member

33 Posts

Posted - 2009-10-06 : 14:48:38
I've already got this statement in our ascx.cs:

strQuery.Append("SELECT TITLE, ARTICLEID, VIDEOARCHIVED, SUMMARY, DATE, ");
strQuery.Append("SUBSTRING(TITLE,1,1) AS 'BREAK'");
strQuery.Append(" from Article ");
strQuery.Append(" WHERE (Article.Deleted <> 1 OR Article.Deleted IS NULL) AND (Article.CATEGORYID IS NOT NULL OR Article.CATEGORY2ID IS NOT NULL)");


So I figured I could just SELECT 'Name' and then JOIN the Author and Article table by AuthorID since the 'Name' column is located in the Author table..
Go to Top of Page
   

- Advertisement -