Connecting Tech Pros Worldwide Help | Site Map

HI good day to all... i have a problem on how to connect the 2 tables in a database?

Newbie
 
Join Date: Sep 2009
Posts: 6
#1: Sep 3 '09
Im a college student, my program is a computerized enrollment system, Im using MS ACCESS database in connecting my VB6 program form. Inside i'd created two tables, named "tbstudentinfo" and "tbstudentfees". In my 1st table i renamed my fieldname to STUDENTNUMBER and STUDENTNAME on the second fieldname, then below i entered (0001) for studnumber and (Paul) for studname. The 2nd table is almost the same with the 1st table but i added another fieldname (STUDFEES) and entered 5000 below. But my problem is on how to connect the 1st table to the 2nd table, i mean in the 1st table i entered the student number and the name of the person who enrolled. Then in the 2nd table, student payment or fees i need only to type the student number "like a search engine" and it will automatically shows the name that i'd entered in my 1st table and that will show in my VB6 program form running mode then saved it in my database. So i need a simple sample code or a whole simple code or a sample related to this system that i can understand definitely the code. Before i forget im currrently using ADODC database MS ACCESS connection. I hope you understand my problem and share your precious knowledge to someone really need it the most, to become successful someday in programming and i promised that GOD will bless you, not once but twice. And Thanks in advance to those who read and post their helpful codes, from the bottom of my heart.

if you have a simple way like using MODULE just give a code that can easily understand x) cause i dont know how to use MODULE in connecting 2 tables in a single database.
debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,499
#2: Sep 3 '09

re: HI good day to all... i have a problem on how to connect the 2 tables in a database?


to connect two tables at database level you need to use primary key and foreign key.
Newbie
 
Join Date: Sep 2009
Posts: 6
#3: Sep 4 '09

re: HI good day to all... i have a problem on how to connect the 2 tables in a database?


last thing, u can share and send your vb6 program related to at mail id snipped your kind is much appreciated
Newbie
 
Join Date: Nov 2008
Posts: 23
#4: Sep 4 '09

re: HI good day to all... i have a problem on how to connect the 2 tables in a database?


Do you actually need two tables here? Do students have multiple fees each? If you do need two tables you're going to want to do
Expand|Select|Wrap|Line Numbers
  1. tbStudInfo
  2. studno     studname
  3.  
Expand|Select|Wrap|Line Numbers
  1. tbStudfees
  2. studno      studfee
  3.  
then join them using primary and foreign keys on 'studno', as debasisdas said
Newbie
 
Join Date: Sep 2009
Posts: 6
#5: Sep 5 '09

re: HI good day to all... i have a problem on how to connect the 2 tables in a database?


how to use a foreign key i only know the primary key
Reply