Forum Moderators: open
I'm trying to update the payment type column on my access db by clicking a button on one of my payment pages.
Very simply explained:
I have two payment types (pages)
1) Credit card card.asp
2) money transfer transfer.asp
on my transfer.asp, I have a button "confirm" with the hyperlink:
javascript:setpayment()
and the setpayment code on the same page looks like:
<script language="javascript">
function setpayment() {
Set Recordset = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM Orders where ID = '" & guid & "'"
Recordset.Open SQL, Conn, 1, 2
Recordset("OrderType") = "paytype1"
session("OrderType") = Recordset("OrderType")
}
</script>
Note: The guid session have been saved within a page prior to this transfer.asp is loaded.
Problem is: When the transfer.asp page loads, I see on the status bar a completed info with an exclamation mark telling the following:
Line: 114
Char: 7
Error: Expected ';'
Code:0
URL: [localhost...]
The above code looks ok for me but the page is complaining that it is not. I have tried many changes with the code but it didnt help. What could be wrong with the code?
Thanks to all for the comments.
I haven't tested your code, but it looks OK, although it should be surrounded by <% %> instead of <script></script>. And, if it really is an ASP solution you are trying to achieve you cannot call it with a javascript onClick event.
It might be an idea to check [w3schools.com...] they have some great tutorials on ASP and Javascript, you can also see the differences between the two languages.
(btw. javascript lines always end with ';')
I will post the code and the error message I'll receive within the day.
Thanks for your welcome ;-).
<%
Set Recordset = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM Orders where ID = '" & guid & "'"
Recordset.Open SQL, Conn, 1, 2
Recordset("OrderType") = "paytype1"
session("OrderType") = Recordset("OrderType")
Recordset.Update
Recordset.Close
%>
and the error code:
Error Type:
ADODB.Recordset (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/transfer.ASP, line 50
the line 50 is: Recordset("OrderType") = "paytype1"
I'm just trying to update the "OrderType" field within the "Orders" database with "paytype1" for the corresponding session and then session the "ordertype" itself for further reading the value from the corresponding recordset.
That's the reaseon why I did'nt even know that my asp code should be surrounded by <% %> and tried to declare the asp stuff as a javascript
Is it possible to work together with your programmer for general advice? this would give you some direct feedback (instead of having waiting for us to help you).
Either way, feel free to ask questions and share experiences here, there are planty of others in the same boat as you.
Ok I've checked my db.
My "Orders" db. has certainly rows for each session of my customers. This means that each time a customer chooses a payment type, a session ID is produced and written into the db.
But this is done in the session.asp page.
What I want is to populate the 26'th column (the "Ordertype") not on the session.asp page but on the page which has been loaded after the customer has chosen his payment type. This is either the card.asp or the transfer.asp page. Thats where I want to update the "OrderType" record. The main reason is that the customer confirms his/her payment on these pages and I want to track it from there.
I've brought my code working now.
I've changed it like this:
<%
Set Recordset = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM Orders where ID = '" & session("guid") & "'"
Recordset.Open SQL, Conn, 1, 2
If not Recordset.Eof Then
Recordset("OrderType") = "paytype1"
session("OrderType") = Recordset("OrderType")
Recordset.Update
Recordset.Close
End If
%>
I have realized that I have saved the customers session guid in the session.asp page that way:
Recordset2("ID") = guid (guid was created before if no guid is present)
session("guid") = Recordset2("ID")
so instead just choosing the row with "guid" I have chosen the row with "session("guid")" which worked.
I thought it would also work with just "guid" but it didn't. I don't know why.