Hi
I'm using VB.NET,ADO.NET in ASP.NET .
Microsoft .Net framework 1.0
Windows 2000
Visual Studio IDE
and SQLServer.
I have to create to tables as
Table1 contains ID,Name
Table2 contains ID,Marks,Foreign Key ie Primary key of the table Table1.
Give me an information how to create these two tables in SQLServer (I know how to create a table but i don't know how to create a table which includes Foreign Key.)
Then using Dataset i want to display the records as Name,Marks which are stored in two tables.
I have studied that in ADO Join query and record set object is used but it gives a problems and it is not good when we want to transfer the data between two applications or pages but dataset solves all those problems.
Give me an information about it.
Kindly help me
Thanks in advance
Regards.
To create table with Foreign key constraint using T-SQL:
create table tbl_PK (ID int primary key,name varchar(30))
go
create table tbl_FK (ID int foreign key REFERENCES tbl_PK(ID),
Marks varchar(50))
To get the joined result:
select p.name,f.marks from tbl_PK p join tbl_FK f
on p.ID=f.ID
Hi
What you have given is also a join query.but i have studied that no need of join query in case of dataset but it is required for record set.
Thanks
|||To do that, please take a look a the following short movie:http://msdn.microsoft.com/vstudio/express/media/en/AbsoluteBeginner/vb/08VB.wvx
This is tutorial movie about VWD 2005 and SQL server EE, I believe you can also apply it to VS 2005 because the similarity.
Basically what you do is you create database diagram with right clickon 'Database Diagram' under the Database explorer of your databasefilename. Then add new diagram. After that you can add all your tables,then drag the primary key to create the foreign key.
hope this will help.
No comments:
Post a Comment