Results 1 to 9 of 9

Thread: Datagrid forum??

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    UK
    Posts
    271

    Datagrid forum??

    Hi,

    I'm currently creating as forum using ASP.Net - VB
    I have managed to produce the multiple forums, and the threads,

    but its when you go into the threads, and you get the main post, then the replies.

    I have used a datagrid to show all the information such as Avatar, poster details, message etc,

    but I am not sure hwo I get the replies into the datagrid, I have selected all the reply data in my SQL statement so all the fields are ready to insert.

    The problem is that if I put the the data into the Datagrid it wont show the information as another row?
    so any ideas how I can do this?

    Thanks,
    §tudz

    Studzworld.com - Portfolio

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I am not sure what you are saying. What I did with my forums is get the topic, and unioned in SQL Server the replies. This returns one result set to bind to the datagrid. They are nothing special, but you can view them here:
    www.variantx.com/vxforums/

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    UK
    Posts
    271
    from looking at your forum, mine is the same sort of set up.

    you have the forums which go to the threads, and then the threads lead to the thread and its replies.

    did you put your threads and replies into two different tables?

    and if so how did you get the thread to appear as well as its replies?

    Thanks
    §tudz

    Studzworld.com - Portfolio

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    That was what I was trying to explain. I have two tables, topic posts, and replies. What I do is select the topic post, and UNION the replies so one result set is returned to the dataset. I then bind the dataset to the grid. If you don't know what I am talking about when I say UNION, look in the SQL server help documents for UNION.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    UK
    Posts
    271
    thanks,


    [goes to find sql book]
    §tudz

    Studzworld.com - Portfolio

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    UK
    Posts
    271
    ok, seeing that a Union is also called an outer join, can you have multiple union joins the same as inner joins? if so how?
    §tudz

    Studzworld.com - Portfolio

  7. #7
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    No, a union is not a join.

    What it does, is take two result sets and makes them one result set. So, when you select the topic post, it will be in one result set, and when you select the reply post records, they will be in another. You need to union those to make just one recordset returned.

    Here is my stored procedure:
    Code:
    CREATE PROCEDURE dbo.spVXGetTopicDetails
    	@TopicID int
    AS
    
    	/* Get the topic post, along with the replies */
    	SELECT 'Topic' as 'Table', VX_Topics.TopicID, VX_Topics.UserName, VX_Topics.Title, VX_Topics.PostDate, VX_Topics.Message, VX_Users.EmailAddress, VX_Users.AllowToBeEmailed, VX_Users.PostCount, VX_Users.DateRegistered, VX_Users.Location, VX_Users.Signature FROM VX_Topics
    	JOIN VX_Users ON VX_Users.UserName = VX_Topics.UserName
    	WHERE VX_Topics.TopicID = @TopicID
    	UNION ALL
    	SELECT 'Reply' as 'Table', VX_Replies.ReplyID, VX_Replies.UserName, VX_Replies.Title, VX_Replies.PostDate, VX_Replies.Message, VX_Users.EmailAddress, VX_Users.AllowToBeEmailed, VX_Users.PostCount, VX_Users.DateRegistered, VX_Users.Location, VX_Users.Signature FROM VX_Replies
    	JOIN VX_Users ON VX_Users.UserName = VX_Replies.UserName
    	WHERE VX_Replies.TopicID = @TopicID ORDER BY PostDate
    RETURN

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    UK
    Posts
    271
    right ok,

    but how did you put it intot the datagrid? as binding it to it would just show the thread, then the reply then the thread then the next reply, wouldn't it?
    §tudz

    Studzworld.com - Portfolio

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    UK
    Posts
    271
    thanks it works now, sorted it, thanks for the help
    §tudz

    Studzworld.com - Portfolio

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width