Terry Wingfield
Member
- Joined
- Sep 2, 2009
- Messages
- 12
- Programming Experience
- Beginner
Hey Guys, i am new to all this and very much in need of some advice.
I have constructed a SQL select statement that displays a basic forum structure interface I.E:
Forum Name, Threads and LastPost
But for some reason when i add the SQL statement to the SQLDataSource and then hook the SQLDataSource to a gridview it displays empty.
I have had this working before, but through a serious of individual select statements that use hard coded values which is very ineffeicent.
My SQL select statment as follows:
SELECT TOP (1) ThreadsTable.Subject, MessageTable.Author, MessageTable.Date, TopicTable_1.TopicTableID,
(SELECT Description
FROM TopicTable
WHERE (TopicTableID = @TopicTableID)) AS Description,
(SELECT Name
FROM TopicTable AS TopicTable_2
WHERE (TopicTableID = @TopicTableID)) AS Forums,
(SELECT COUNT(*) AS Expr1
FROM ThreadsTable AS ThreadsTable_1
WHERE (TopicTableID = @TopicTableID)) AS Threads
FROM TopicTable AS TopicTable_1 INNER JOIN
ThreadsTable AS ThreadsTable ON TopicTable_1.TopicTableID = ThreadsTable.TopicTableID
INNER JOIN
MessageTable ON ThreadsTable.ThreadsTableID = MessageTable.ThreadsTableID
WHERE (TopicTable_1.TopicTableID = @TopicTableID)
ORDER BY MessageTable.Date DESC
I hope this can be rectified and Thanks in advance for the advice given.
Regards
Tez
I have constructed a SQL select statement that displays a basic forum structure interface I.E:
Forum Name, Threads and LastPost
But for some reason when i add the SQL statement to the SQLDataSource and then hook the SQLDataSource to a gridview it displays empty.
I have had this working before, but through a serious of individual select statements that use hard coded values which is very ineffeicent.
My SQL select statment as follows:
SELECT TOP (1) ThreadsTable.Subject, MessageTable.Author, MessageTable.Date, TopicTable_1.TopicTableID,
(SELECT Description
FROM TopicTable
WHERE (TopicTableID = @TopicTableID)) AS Description,
(SELECT Name
FROM TopicTable AS TopicTable_2
WHERE (TopicTableID = @TopicTableID)) AS Forums,
(SELECT COUNT(*) AS Expr1
FROM ThreadsTable AS ThreadsTable_1
WHERE (TopicTableID = @TopicTableID)) AS Threads
FROM TopicTable AS TopicTable_1 INNER JOIN
ThreadsTable AS ThreadsTable ON TopicTable_1.TopicTableID = ThreadsTable.TopicTableID
INNER JOIN
MessageTable ON ThreadsTable.ThreadsTableID = MessageTable.ThreadsTableID
WHERE (TopicTable_1.TopicTableID = @TopicTableID)
ORDER BY MessageTable.Date DESC
I hope this can be rectified and Thanks in advance for the advice given.
Regards
Tez