Problem with deleting records using jquery with classic asp
Hi
I'm using jquery to pass trough data to another page where I want to insert and delete a record. But the problem is that jquery only inserts or deletes the records and not both together.
I use following code:
For jquery:
- $(document).ready(function(){
- $("#btnAddPayment").click(payment);
- });
- //example 1
- function payment(){
- $.ajax({
- type:"POST",
- url: "acceptPaymentExecute.asp",
- dataType: "application/x-www-form-urlencoded",
- data: "amount=" + $("#amount").val() + "&reason=" + $("#reason").val() + "&bookingDate=" + $("#bookingDate").val() + "&accountNumber=" + $("#accountNumber").val() + "&memberID=" + $("#memberID").val() + "&memberPaymentID=" + $("#memberPaymentID").val(),
- success: function(msg){ $("#fldPayment").append(msg);}
- })
- }
In my acceptPaymentExecute.asp page:
- amount = Request("amount")
- bookingdate = Request("bookingDate")
- reason = Request("reason")
- accountNumber = Request("accountNumber")
- memberID = Request("memberID")
- memberPaymentID = Request("memberPaymentID")
- set objConn = Server.CreateObject("ADODB.Connection")
- set objRS = Server.CreateObject("ADODB.Recordset")
-
- objConn.open conn
- yearDate = Year(bookingdate)
- bookDate = Year(bookingdate) & "-" & Month(bookingdate) & "-" & Day(bookingdate)
- strInsertPayment = "INSERT INTO payment(memberID,amount,bookingdate,reasonPayment,paymentYear,accountNumber) VALUES (" & memberID & "," & amount & ",'" & bookDate & "','" & reason & "'," & yearDate & "," & accountNumber & ");"
- strDeleteMemberPayment = "DELETE FROM memberPayment WHERE memberPaymentID = " & memberPaymentID & ";"
- objRS = objConn.execute(strInsertPayment)
- objRS = objConn.execute(strDeleteMemberPayment)
- objRS.close()
- set objRS = nothing
- objConn.close()
- set objConn = nothing
The queries work but not together. If I comment the insert statement, my page executes the delete statement, ...
I already tried to call another object for my delete statement but it does the same.
Can somebody help me with this problem?