Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 20-07-2005, 09:31 AM
azmaliya's Avatar
Novice Webmaster
 
Join Date: Jul 2005
Location: kl
Posts: 11
Rep Power: 0
azmaliya is on a distinguished road
Send a message via Yahoo to azmaliya
insert data into multiple table

hai.. kite nak tanya... bley tak nak masukkan data ke dalam byk table dlm satu borang menggunakan coldfusion.. klu bley,tlg tunjuk ajar..
trimas...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 22-07-2005, 12:15 PM
Jacky's Avatar
Novice Webmaster
 
Join Date: Jul 2005
Location: KL
Posts: 68
Rep Power: 43
Jacky is on a distinguished road
Easy. Just use 2 or more SQLs to insert into 2 or more tables.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 25-07-2005, 03:35 PM
azmaliya's Avatar
Novice Webmaster
 
Join Date: Jul 2005
Location: kl
Posts: 11
Rep Power: 0
azmaliya is on a distinguished road
Send a message via Yahoo to azmaliya
kite dah cube guna 2 sql yg berbeza tp ader error.. mcm mana ek?
plzzz ader sesape leh tolong???

nie sql nye...

<cfquery name="add_peminjam" datasource="maklumat" username="" password="">
INSERT INTO peminjam (nama, bahagian) VALUES ('#Form.nama#', '#Form.bahagian#')
</cfquery>

<cfquery name="add_tarikh" datasource="maklumat" username="" password="">
INSERT INTO pinjam (tarikhpinjam, tarikhjangkapulang) VALUES ('#Form.tarikhpinjam#', '#Form.tarikhjangkapulang#')
</cfquery>



yg nie plak error nye..

Error Occurred While Processing Request
Error Diagnostic Information
ODBC Error Code = 23000 (Integrity constraint violation)


[Microsoft][ODBC Microsoft Access Driver] You cannot add or change a record because a related record is required in table 'peminjam'.



The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (11:1) to (11:73).


Date/Time: 07/25/05 15:27:15
Browser: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; (R1 1.5))
Remote Address: 127.0.0.1
HTTP Referrer: http://localhost/baru/pinjam.cfm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 25-07-2005, 04:59 PM
Jacky's Avatar
Novice Webmaster
 
Join Date: Jul 2005
Location: KL
Posts: 68
Rep Power: 43
Jacky is on a distinguished road
Oh, this is due to "Integrity constraint violation". Your pinjam table has 2 fields only? Most likely it has more fields and these other fields (especially the field that corresponds to the primary key "nama" in "peminjam") have to be updated also. If you update 2 fields only, then out the error...

Cheers.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 25-07-2005, 05:30 PM
azmaliya's Avatar
Novice Webmaster
 
Join Date: Jul 2005
Location: kl
Posts: 11
Rep Power: 0
azmaliya is on a distinguished road
Send a message via Yahoo to azmaliya
adakah u maksud kan kena tambah atribut 'nama' dlm table pinjam?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 25-07-2005, 05:50 PM
Novice Webmaster
 
Join Date: May 2002
Location: Kuala Lumpur, Malaysia
Posts: 36
Rep Power: 0
victor is on a distinguished road
Send a message via ICQ to victor Send a message via AIM to victor Send a message via Yahoo to victor
Structure

Juz show us your table structure here
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 26-07-2005, 10:00 AM
azmaliya's Avatar
Novice Webmaster
 
Join Date: Jul 2005
Location: kl
Posts: 11
Rep Power: 0
azmaliya is on a distinguished road
Send a message via Yahoo to azmaliya
table

ok.. nie die table kite...

pinjam (nopinjam,nopeminjam,nosiriinventori,tarikhpinjam, tarikhjangkapulang,tarikhpulang)

peminjam(nopeminjam,nama,bahagian)

klu kite guna sql mcm kat atas tuh mmg error tapi data bley masuk dlm table peminjam sahaja.. nape ekk???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 26-07-2005, 11:42 AM
Jacky's Avatar
Novice Webmaster
 
Join Date: Jul 2005
Location: KL
Posts: 68
Rep Power: 43
Jacky is on a distinguished road
Data is not being inserted into "pinjam" - this is because of "Integrity constraint violation".
I guess nopeminjam is an autonumber field? You need to get this autonumber value and insert into pinjam.nopeminjam. That should solve the problem.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 26-07-2005, 12:27 PM
azmaliya's Avatar
Novice Webmaster
 
Join Date: Jul 2005
Location: kl
Posts: 11
Rep Power: 0
azmaliya is on a distinguished road
Send a message via Yahoo to azmaliya
ok

ok,nopeminjam mmg autonumber... kat mana nak letak coding insert into pinjam.peminjam tuh?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 26-07-2005, 05:01 PM
Novice Webmaster
 
Join Date: May 2002
Location: Kuala Lumpur, Malaysia
Posts: 36
Rep Power: 0
victor is on a distinguished road
Send a message via ICQ to victor Send a message via AIM to victor Send a message via Yahoo to victor
MMmmMMMmmmm

INSERT INTO peminjam (nama, bahagian) VALUES ('#Form.nama#', '#Form.bahagian#')

INSERT INTO pinjam (tarikhpinjam, tarikhjangkapulang) VALUES ('#Form.tarikhpinjam#', '#Form.tarikhjangkapulang#')

pinjam (nopinjam,nopeminjam,nosiriinventori,tarikhpinjam, tarikhjangkapulang,tarikhpulang)

peminjam(nopeminjam,nama,bahagian)


Sounds like you have a foregin key relationship set up, and you are not supplying a valid record id.

If you set pinjam..nopeminjam = autonumber, relationship between pinjam..nopeminjam and peminjam..nopeminjam will b revoke due to there were no matching id between pinjam.nopeminjam and peminjam.nopeminjam.

For table..pinjam, set nopinjam to primarykey and autonumber, then drag the id from peminjam.nopeminjam and insert it back to your pinjam..nopeminjam (do not put pinjam.nopeminjam as autonumber).

e.g.

INSERT INTO peminjam (nama, bahagian) VALUES ('#Form.nama#', '#Form.bahagian#')

then

select @nopeminjam from peminjam order by nopeminjam desc

then

INSERT INTO pinjam (nopeminjam, tarikhpinjam, tarikhjangkapulang) VALUES (@nopeminjam,'#Form.tarikhpinjam#', '#Form.tarikhjangkapulang#')

end
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 27-07-2005, 12:57 PM
azmaliya's Avatar
Novice Webmaster
 
Join Date: Jul 2005
Location: kl
Posts: 11
Rep Power: 0
azmaliya is on a distinguished road
Send a message via Yahoo to azmaliya
aiiyakk...

ok, nie semua table & atribut yg sy ader

peminjam (nopeminjam (autonumber & primary key), nama, bahagian)

pinjam (nopinjam (autonumber & primary key), nopeminjam, nosiriinventori, tarikhpinjam, tarikhjangkapulang, tarikhpulang)

inventori (nosiriinventori (primary key), jenis, model, kodhartamodal, harga)

aksesori (nosiri (primary key), nosiriinventori, jenis, model)

1st, bley tak kite nak tau... ape fungsi "@" pd @nopeminjam tuh..

2nd... sql yg sy wat still tak jadi... ader error

<cfquery name="add_peminjam" datasource="maklumat" username="" password="">
INSERT INTO peminjam (nama, bahagian) VALUES ('#Form.nama#', '#Form.bahagian#')
</cfquery>

<cfquery name="add_nopeminjam" datasource="maklumat" username="" password="">
select @nopeminjam from peminjam order by nopeminjam desc
</cfquery>

<cfquery name="add_tarikh" datasource="maklumat" username="" password="">
INSERT INTO pinjam (nopeminjam, tarikhpinjam, tarikhjangkapulang) VALUES (@nopeminjam,'#Form.tarikhpinjam#', '#Form.tarikhjangkapulang#')
</cfquery>

yg nie plak errornye

Error Occurred While Processing Request
Error Diagnostic Information
ODBC Error Code = 07001 (Wrong number of parameters)


[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

Hint: The cause of this error is usually that your query contains a reference to a field which does not exist. You should verify that the fields included in your query exist and that you have specified their names correctly.


The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (11:1) to (11:77).


Date/Time: 07/27/05 12:24:37
Browser: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; (R1 1.5); FDM)
Remote Address: 127.0.0.1
HTTP Referrer: http://localhost/baru/pinjam.cfm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 27-07-2005, 01:13 PM
Novice Webmaster
 
Join Date: May 2002
Location: Kuala Lumpur, Malaysia
Posts: 36
Rep Power: 0
victor is on a distinguished road
Send a message via ICQ to victor Send a message via AIM to victor Send a message via Yahoo to victor
Talking

Dear azmaliya,

What i mean is that you need to drag the last noPeminjam from your peminjam table and put it back to your pinjam table.

As for select @nopeminjam from peminjam order by nopeminjam desc, @nopeminjam is something that you need to declare and put it back into your PINJAM table.

BTW, for your information @ = SQL StoredProcedure/Trigger language, which we use that to declare something, it is nothing to do with you CFM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 27-07-2005, 01:15 PM
Jacky's Avatar
Novice Webmaster
 
Join Date: Jul 2005
Location: KL
Posts: 68
Rep Power: 43
Jacky is on a distinguished road
  #14 (permalink)  
Old 27-07-2005, 01:57 PM
azmaliya's Avatar
Novice Webmaster
 
Join Date: Jul 2005
Location: kl
Posts: 11
Rep Power: 0
azmaliya is on a distinguished road
Send a message via Yahoo to azmaliya
jgn lah gelak kan kite... kite baru nak blaja tauu...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 29-07-2005, 11:54 AM
azmaliya's Avatar
Novice Webmaster
 
Join Date: Jul 2005
Location: kl
Posts: 11
Rep Power: 0
azmaliya is on a distinguished road
Send a message via Yahoo to azmaliya
hello there.... it's me again.. still tak dpt lagi lah.. tlg lah kite....

kali nie kite try wat mcm nie plak.. tp tak jadi jgk..

<cfquery name="add_peminjam" datasource="maklumat" username="" password="">
INSERT INTO peminjam (nama,bahagian) VALUES ('#Form.nama#','#Form.bahagian#');
select @nopeminjam from peminjam order by nopeminjam desc
</cfquery>

<cfquery name="add_tarikh" datasource="maklumat" username="" password="">
INSERT INTO pinjam (nopeminjam,tarikhpinjam,tarikhjangkapulang) VALUES ('#add_peminjam.nopeminjam#','#Form.tarikhpinjam#' , '#Form.tarikhjangkapulang#')
</cfquery>


Error Occurred While Processing Request
Error Diagnostic Information
ODBC Error Code = 37000 (Syntax error or access violation)

[Microsoft][ODBC Microsoft Access Driver] Characters found after end of SQL statement.

The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (8:1) to (8:75).

Date/Time: 07/29/05 11:53:08
Browser: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; (R1 1.5); FDM)
Remote Address: 127.0.0.1
HTTP Referrer: http://localhost/baru/pinjam.cfm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
insert php in html sloth Website Programming 7 26-08-2005 07:34 PM
checking multiple emails from multiple domain mrbadak Mamak Stall 4 28-06-2005 08:59 PM
Multiple data koisempoi Website Programming 5 06-12-2004 10:51 AM
insert multiple data vash Website Programming 4 28-04-2004 02:48 PM