Link to home
Start Free TrialLog in
Avatar of DasmunchenC
DasmunchenC

asked on

retreiving data from a database with related tables

hello all,

 im currently trying to build a simple bulletin board system (ASP.NET) which enables users to ask questions and add replies. so far i have built a database with 3 tables (topics, replies and posts) and bound the topics to 1 datagrid and the posts table to another for display on another page. the first page lists the topics(or questions asked)in a datagrid then a select button will link to another page showing 1 datagrid with the question and another underneath which i want to bind the replies too. my problem is that i need to relate the replies to the original question so only the replies in the replies table that are relevant to the question are shown in the datagrid underneath. sound confusing? - tell me about it. im sure most of you already know how a "proper" bulletin system works but it is too complicated for me so i have tried to break it down into easy to understand blocks.

Can anyone suggest how i can show the related replies only?

regards,
dasC
Avatar of FrostBite
FrostBite

What are you using for a database?
If I think I know what you mean. You have a buch of topics and whem you click on them you want the main topics and the replies. The easist thing to do is when you click on a topic you pass a TopicID to the next page. In the next page you look in the db. Wich replies have that TopicID. The query might be:
SELECT * FROM Replies WHERE TopicID='TopicID' the word between '' is the variable which you van call with the GET method. The URL of the link might be. http://bulletinboard.com/Replies.aspx?TopicID=33. I hope this helps. Good luck.
Avatar of DasmunchenC

ASKER

im using access from office xp
I agree with CoenMeerbeek.  You could use Access Visual Query editor to draw the relationships between tables (then you can view the SQL statements if you are not familiar with access SQL).  You will need 1 common field to cross reference all the tables (usually a primary key in the main table and a number in the rest).

Hope this helps.
how can i make a variable available to pass from page to page in c# and asp.NET?
ASKER CERTIFIED SOLUTION
Avatar of FrostBite
FrostBite

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thx for all the help guys, with frosrbites tip i figured out how to do it in the code as im not so hot with databases:)
regards
das