ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old August 1st, 2003, 10:41 PM
zalia zalia is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: brunei
Posts: 4 zalia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy How to transfer records from one table of a database to another table in another data

Hi all,

i have aproblem to transfer a data from table x to table y based on id. Its mean when 2 table have same id all data table x must move to table y. I don't know which command need to use is it insert into or update? Can someone help me, i'm new in ASP programming.

here the script i make it

<%
Dim conn
Dim rs
Dim MYSQL,MYSQL2

Set conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
Set cmd = Server.CreateObject("ADODB.Recordset")
conn.ConnectionString = "DSN=prmm;UID=administrator;pwd=sa"
conn.Open

startdate=request("tarikh1")
enddate=request("tarikh2")


MYSQL = "SELECT * FROM table_x where paymentdate between '" & tarikh1 & "' and '" & tarikh2 & "'"
rs.open MYSQL,conn

if rs.EOF then
response.Write("no data")
else
if ([table_x.id] = [table_y.id]) then
MYSQL2 = "INSERT INTO table_y (paymentdate, status, no_resit) values ('" & rs ("paymentdate") & "', '" & rs ("status") & "', '" & rs ("no_resit") & "')"
Set rs = conn.Execute(MYSQL2)

response.write "<p>" & "<center>" & "All data have been done to transfer" & "</center>" & "</p>"
response.write "<p>" & "<A HREF=javascript:history.go(-1)>" & "GoBack" & "</a>"
else
response.write "Cannot transferring the data"
response.write "<p>" & "<A HREF=javascript:history.go(-1)>" & "GoBack" & "</a>"
end if
end if

Set rs = Nothing
Set conn = Nothing
%>

the error meesage i get like below

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert the value NULL into column 'id', table 'rumahmampumilik.dbo.table_y'; column does not allow nulls. INSERT fails.

i don't understand i'm not insert the id

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > How to transfer records from one table of a database to another table in another data


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway