How to insert datas from one table to another using ADO connection

Reply

Join Date: Aug 2008
Posts: 5
Reputation: imagetvr is an unknown quantity at this point 
Solved Threads: 0
imagetvr imagetvr is offline Offline
Newbie Poster

How to insert datas from one table to another using ADO connection

 
0
  #1
Sep 8th, 2008
Hello

I am using windows XP

I need a small programme in Visual basic 6 with Access 2000

I have two tables for example one table named student other table named section

In student table rno is primary key. In section table Rollno is primary key


Both tables have datas, I want to insert datas from student to section.

The coditions is unique datas only (ie. some datas already in section while inserting
datas from student to section the existing datas should be eliminated they wont be inserted)
( by comparin rno with rollno)

Please me code for inserting tables using ADODB recordset




A.Senthil kumar
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 58
Reputation: guest11 is an unknown quantity at this point 
Solved Threads: 2
guest11 guest11 is offline Offline
Junior Poster in Training

Re: How to insert datas from one table to another using ADO connection

 
0
  #2
Sep 11th, 2008
if rno and Rollno are same then try this query

INSERT INTO Section(FirstName, LastName)
SELECT FirstName, LastName FROM Student where student.rno=section.rollno

i hope it will work
Last edited by guest11; Sep 11th, 2008 at 9:13 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 44
Reputation: K.Vanlalliana is an unknown quantity at this point 
Solved Threads: 3
K.Vanlalliana K.Vanlalliana is offline Offline
Light Poster

Re: How to insert datas from one table to another using ADO connection

 
0
  #3
Sep 11th, 2008
You can do this in a number of way, one simple way is that,


1. if you want to insert only student whose info is in students table but not in Section table,
then select uisng this SQL

SQL= "SELECT * FROM Student WHERE rno NOT IN(SELECT DISTINCT Rollno FROM section WHERE Student.rno= section.Rollno)ORDER BY rno"

The Above SQL will select only those student which are not in the Section table so that you can insert all the elected list to the Section Table by using AddNew command.

Try this, its so simple. There a number of way for this.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC