Current location: Hot Scripts Forums » Programming Languages » ASP » moving data from table to table ..please help!


moving data from table to table ..please help!

Reply
  #1 (permalink)  
Old 09-22-03, 12:59 PM
geneane's Avatar
geneane geneane is offline
Newbie Coder
 
Join Date: Sep 2003
Location: The Carolinas
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Smile moving data from table to table ..please help!

I need to create a link or button on the view pagevthat when clicked, will move the information from the current table to another table and open an add recird page with the info already in the fields from the original table.

i.e. insert into table2 (select * from table 1)
(I found this sql statement at http://forums.aspfree.com/archive/5/2003/9/3/18578

except Table 2 has more fields than Table 1 so I do not think I can just copy * to the new table.


Table 1
========
QID
Question
Notes
DateStamp


Table 2
========
QID
TopicID
Question
Notes
Hits
Status
DateStamp
ModifiedDate

The field 'question' and 'Notes' are the only fields that need to be moved. 'QID' and 'DateStamp' are automatically filled.

Is this possible? Could someone please help?
Thanks a million!
Reply With Quote
  #2 (permalink)  
Old 09-22-03, 06:46 PM
Shane Shane is offline
Coding Addict
 
Join Date: Jun 2003
Location: Maryland, US
Posts: 268
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by geneane
I need to create a link or button on the view pagevthat when clicked, will move the information from the current table to another table and open an add recird page with the info already in the fields from the original table.

i.e. insert into table2 (select * from table 1)
(I found this sql statement at http://forums.aspfree.com/archive/5/2003/9/3/18578

except Table 2 has more fields than Table 1 so I do not think I can just copy * to the new table.


Table 1
========
QID
Question
Notes
DateStamp


Table 2
========
QID
TopicID
Question
Notes
Hits
Status
DateStamp
ModifiedDate

The field 'question' and 'Notes' are the only fields that need to be moved. 'QID' and 'DateStamp' are automatically filled.

Is this possible? Could someone please help?
Thanks a million!
Create a select all on the first table and create a loop that loops through each record. During the loop, just generate an insert statement on the fly and execute it.

For example:
Code:
Set RS = conn.Execute("select * from tblName")

While NOT RS.EOF

strName = RS("name")
strEmail = RS("email")

sql = "insert into tblNew(name,email) values('" & strName & "','" & strEmail & "')"

conn.Execute(sql)
RS.MoveNext
Wend

RS.Close
conn.Close

Set RS = Nothing
Set conn = Nothing
Something like that..
__________________
Shane Bauer
Microsoft Certified Professional (MCP) - ASP.NET
ASP/ASP.net, C#, VB/VB.NET, PHP, Perl, SQL
Reply With Quote
  #3 (permalink)  
Old 09-22-03, 07:02 PM
geneane's Avatar
geneane geneane is offline
Newbie Coder
 
Join Date: Sep 2003
Location: The Carolinas
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks a million....got it working.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Validator ctrl in table cell : Strange behaviour sunny_doncaster ASP.NET 6 07-31-08 09:43 AM
Linking in table perleo PHP 2 10-09-03 12:41 PM
Print data by date perleo PHP 2 08-09-03 09:35 AM
Mail Script sending multiple times when Table has a lot of data dsumpter PHP 12 07-16-03 05:17 PM
cannot display the complete data najmun PHP 2 07-04-03 02:52 PM


All times are GMT -5. The time now is 03:35 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.