Forums

ASP

This topic is locked

MS Access update problem?

Posted 28 Jul 2003 02:52:47
1
has voted
28 Jul 2003 02:52:47 Ross Calvert posted:
I am currently trying to make my own forum using a ms access database and dreamweaver mx to help me to create the pages i have a question table and reply table. When somebody submits a reply the information is fed into the reply table. Can anybody tell me how i can write to the question table at the same time (NoOfReplies) and the best way to increment the number each time.
Thanks in advance.

Replies

Replied 29 Jul 2003 04:09:30
29 Jul 2003 04:09:30 Dan Berdusco replied:
I can think of 2 ways that you can do this (There are probably dozens). The first way to count the number of replies for each topic would be to perfom an actual count of the number of records in the reply table (This is assuming that your question table is linked to your reply table). For Example, if you have a question in the question table (and it has a QuestionID of 1) and you want to know how many replies there are for that specific question, perform a count for the number of replies in the reply table with that same QuestionID. I wouldn't recommend this way because it could bog down MS Access if you have several questions that it has to count all of the replies for each one.

The second way would be to have a field in the questions table for the number of replies that increments by one each time a user replies. What you can do it put a piece of code on a page after the user has replied that will add one to the count field (NoOfReplies). You could use something like this:

<pre id=code><font face=courier size=2 id=code>
&lt;%
RS_Name("NoOfReplies"=RS_Name("NoOfReplies"+1
RS_Name.Update()
%&gt;
</font id=code></pre id=code>

Hope that helps.

Reply to this topic