Forum Moderators: open

Message Too Old, No Replies

Expected ";" although the small code looks ok.

updating an access database with javascript.

         

fototex

12:25 pm on Jul 4, 2009 (gmt 0)

10+ Year Member



Hi friends,
Ihave transferred the topic to this subject section upon an advise of a senior member of the forum. I hope I'm correct here.

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.

marcel

5:15 pm on Jul 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure of what you are trying to achieve here, use Javascript or ASP? Your code block looks like ASP but in the script declaration you declare it as javascript.

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 ';')

marcel

6:25 pm on Jul 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I see that you're new here Fototex, Welcome to WebmasterWorld [webmasterworld.com]!

fototex

7:56 pm on Jul 4, 2009 (gmt 0)

10+ Year Member



Yes I am absolutely new here.
Well the fact is that I have a programmer which carries all the programming stuff. I've never worked with asp codes. I'm just familiar with some javascript integration and the design itself.
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:)
Although it may take some time for me, I've decided to go a step further and understand the whole .asp stuff while my programmer takes care after her new project.

I will post the code and the error message I'll receive within the day.

Thanks for your welcome ;-).

fototex

8:20 pm on Jul 4, 2009 (gmt 0)

10+ Year Member



Here is the final code:

<%
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.

janharders

8:27 pm on Jul 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You did not check wether you actually got a record from the database. maybe there is no row that matches your sql?

marcel

8:32 pm on Jul 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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

No worries fototex, we all have to start somewhere :)

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.

fototex

8:59 pm on Jul 4, 2009 (gmt 0)

10+ Year Member



Sure, I always do work with my programmer but she's having her vacation for the next two weeks and I just did'nt want to wait that much. So for not to have to wait for some weeks each time, I felt that have to take it over slowly.

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.

fototex

9:25 pm on Jul 4, 2009 (gmt 0)

10+ Year Member



Hi friends,

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.