Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have to table in access

table No,1 Content
Names , Students grade
qassem . 300
noor    . 280


table No,2 content

schoolsName , Students grade
aaaaaaa   .   290
bbbbbbb    . 270
ccccccc    . 250


i want to link those table with us in C# 2012 visual studio

When the students' final grades open them all schools

After that each student opens his choices by grade given to him

I can not link to them
thank you
i am Egyptian
A few my knowledge in English
Posted
Updated 23-Jun-16 20:00pm
v2
Comments
Sergey Alexandrovich Kryukov 23-Jun-16 16:59pm    
Not clear. Do you have a relational database? If you want to express some relationship, you have to describe the relationship somehow. In your example, there is no any sign of any relationships.

It's also hard to help you, because it's hard to understand what is your background and what you are using. In relational model, the relationships is established by using unique keys and foreign keys...

—SA
Maciej Los 23-Jun-16 17:32pm    
Access is relational database. You can define relationship between tables, Sergey ;)
Sergey Alexandrovich Kryukov 23-Jun-16 18:24pm    
Ah, Access... Perhaps, to me it's a bit hard to spot "access" as "Access". :-)
Thank you.
Well, right; as I say, no relationship is indicated in any way...
—SA
Maciej Los 23-Jun-16 18:34pm    
I'm not sure for 100%. This is my guess...
Yeah, you're right, there's no relationship between tables defined.
Maciej Los 23-Jun-16 17:34pm    
At this moment i do not see any relationship between tables!

You need a primary key in the master table and a Foreign key in the detail table, then from SQL Server managment studio you do the join for this 2 keys and in VB .Net you do the same same join with 2 bindingsource objects.
 
Share this answer
 
The problem is that in order to establish a relationship between tables, they need to have a common value. It's like an MP3: it has a title, but it also has a musician (or band) that made it. So you could have two tables:
Artists:
ID    ArtistName
1     Lana Del Ray
2     Coldplay
...
Because a band or artist is likely to produce more than one track, it makes sense to store them in their own table - otherwise you will be duplicating teh smae band name over, and over again.
And a Tracks table:
Tracks:
ID    ArtistID   TrackName
1     1          Gods and Monsters
2     1          Ride
3     2          Paradise
4     2          Fix You
...

And you can establish a foreign key relationship between the Tracks and Artists on the Tracks.ArtistID and Artists.ID columns.
That lets you fetch related information:
SQL
SELECT a.ArtistName, t.TrackName
FROM Tracks t
JOIN Artists a ON t.ArtistID=a.ID
And that returns you:
Gods and Monsters  Lana Del Ray
Ride               Lana Del Ray
Paradise           Coldplay
Fix You            Coldplay
...
But if you don't have the "linking column" of the ArtistsID then there isn't a way to "connect" the two tables.

But...in your example, you don't want a "link" at all.
What you want to do is check each student grade against the minimum value the schools will accept and show which schools the student can go to.
That's just a simple SQL query:
SQL
SELECT Students.StudentName, Schools.SchoolName FROM Students, Schools
WHERE Students.Grade >= Schools.MinGrade
And that gives you:
StudentName	SchoolName
qassem	    aaaaaaa
qassem	    bbbbbbb
qassem	    ccccccc
noor	    bbbbbbb
noor	    ccccccc
 
Share this answer
 
Comments
Member 12267555 24-Jun-16 4:08am    
OK then i want to get ruselt in text box
what can i do
OriginalGriff 24-Jun-16 4:18am    
What result? The result I show?
How are you accessing the database? It makes a difference to what you do with the data afterwards.
But...Why a text box? This is a table of data, so why not use a grid based display control?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900