S
suzy
it seems like a simple enough problem, but i need some help......
i have a table of messages (like newsgroup messages) in sql server. my
application will allow people to read threads/messages and reply to messages
over the net.
the table has the following columns:
messageId - unique primary key
parent message id - if someone replies to an existing message, the parent
message's id goes here. (if message has no parent then this will be 0).
root message id - the id of the first message in the thread.
subject - the subject of the message
text - the main text of the message.
basically, what i want is to write some code that takes in a root message id
as a parameter, then returns all message in that thread.
however, i need to data to be returned hierarchically, so anything along the
lines of xml is needed. if i could do this using the DataSet object in .NET
it would be ideal.
ideally, the data will be returned in the following format:
<messages>
<message id="1" parentmessageid="0" rootmessageid="1" subject="hello"
text="hi everyone, how are you">
<message id="2" parentmessageid="1" rootmessageid="1" subject="Re:
hello" text="im fine, you?">
<message id="4" parentmessageid="2" rootmessageid="1"
subject="Re: Re: hello" text="im good too!">
</message>
</message>
<message id="3" parentmessageid="1" rootmessageid="1" subject="Re:
hello" text="im terrible.">
</message>
</message>
</messages>
i have a table of messages (like newsgroup messages) in sql server. my
application will allow people to read threads/messages and reply to messages
over the net.
the table has the following columns:
messageId - unique primary key
parent message id - if someone replies to an existing message, the parent
message's id goes here. (if message has no parent then this will be 0).
root message id - the id of the first message in the thread.
subject - the subject of the message
text - the main text of the message.
basically, what i want is to write some code that takes in a root message id
as a parameter, then returns all message in that thread.
however, i need to data to be returned hierarchically, so anything along the
lines of xml is needed. if i could do this using the DataSet object in .NET
it would be ideal.
ideally, the data will be returned in the following format:
<messages>
<message id="1" parentmessageid="0" rootmessageid="1" subject="hello"
text="hi everyone, how are you">
<message id="2" parentmessageid="1" rootmessageid="1" subject="Re:
hello" text="im fine, you?">
<message id="4" parentmessageid="2" rootmessageid="1"
subject="Re: Re: hello" text="im good too!">
</message>
</message>
<message id="3" parentmessageid="1" rootmessageid="1" subject="Re:
hello" text="im terrible.">
</message>
</message>
</messages>