Results 1 to 25 of 34
Thread: Newbie- Simple ASP Help Please
-
05-04-2008, 07:57 PM #1New Member
- Join Date
- May 2008
- Posts
- 2
Newbie- Simple ASP Help Please
Hi.
I am having trouble making my active server page scrip pull some records from a database and put them into a dropdown box. I think, haha.
The code I am using is here, in a text file for you to read: www . joannemahoney . co . uk / cwk / customer_order1 . txt
The problem is somewhere around the select box as far as I have gathered.
The actual system is here: www . joannemahoney. co. uk / cwk / and if you log in with (user: test@joannemahoney.co.uk / pass: lewis) and try to place a new order, then 'add products to order' you will see my problem! Thank you if you can help at all, sorry to bother you if not!
If you need anymore info then please let me know!
I am a very large 'n00b' and I am only doing this for coursework at school but all your help is appreciated.
(also sorry for the spaces in links, it wouldnt let me post without because i didnt have 5 posts!)
-
05-04-2008, 08:10 PM #2New Member
- Join Date
- May 2008
- Posts
- 2
Okay, I think I got a bit of it. The table in the sql query was spelt wrong.. I fixed that but now my script is timing out every time I try and run it. What are the causes? Help please! : )
-
05-04-2008, 08:19 PM #3New Member
- Join Date
- May 2008
- Posts
- 2
Okay - I lied. It stopped timing out but I'm having the same problem. Any offers?
-
05-04-2008, 08:54 PM #4
Since you want offers to help, moved to employment.
-
05-05-2008, 05:30 AM #5New Member
- Join Date
- May 2008
- Posts
- 2
Erm, I actually only wanted offers of help to troubleshoot this one page. I don't want to pay anyone to finish my coursework for me....
-
05-05-2008, 08:15 AM #6WHT Addict
- Join Date
- Sep 2006
- Location
- Indiana
- Posts
- 167
Here's my take based on just looking at your code.
Code:<SELECT name="productname"> <% set conn=server.createobject ("adodb.connection") connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_ Server.MapPath("joannemahoney.mdb") & ";Persist Security Info=False" conn.Open connect set ors=server.createobject("adodb.recordset") strsql = "SELECT productid, bookstock, productname FROM tblProduct WHERE bookstock > 0 ORDER BY productid" ors.open strsql,conn Do while not ors.EOF if request.form("productname")=ors("productname") then response.write "<option value = '"&ors("productid")&"' Selected>" response.write ors("productname") & "</option>" ors.movenext end if loop %> </select>
Code:if request.form("productname")=ors("productname") then response.write "<option value = '"&ors("productid")&"' Selected>" response.write ors("productname") & "</option>" else response.write "<option value = '"&ors("productid")&"'>" response.write ors("productname") & "</option>" end if ors.movenext
[Lurking Glass] <- Not a webhost.
-
05-05-2008, 08:20 AM #7New Member
- Join Date
- May 2008
- Posts
- 2
Ah, thank you very much! I was considering self-harm! Thanks so much again!
-
05-05-2008, 08:30 AM #8New Member
- Join Date
- May 2008
- Posts
- 2
Ah, I am now getting an error:
Code:Microsoft OLE DB Provider for ODBC Drivers error '80040e07' [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. /cwk/customer_order1.asp, line 119
-
05-05-2008, 08:38 AM #9New Member
- Join Date
- May 2008
- Posts
- 2
Updated link with new code, new error still being recieved.
-
05-05-2008, 08:50 AM #10WHT Addict
- Join Date
- Sep 2006
- Location
- Indiana
- Posts
- 167
I'm guessing the new error has something to do with this:
Code:strsql = "SELECT * FROM tblOrderItems WHERE orderid = '"&orderid&"' "
It's trying to get order IDs as text. I'd assume that order IDs are an integer or some similar field. And, if so, try removing the single-quotes around the field data...like this:
Code:strsql = "SELECT * FROM tblOrderItems WHERE orderid = " & int(orderid)
[Lurking Glass] <- Not a webhost.
-
05-05-2008, 08:59 AM #11New Member
- Join Date
- May 2008
- Posts
- 2
Well it gets passed line 119 now, error on 121:
Code:ADODB.Recordset error '800a0bcd' Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. /cwk/customer_order1.asp, line 121
Thanks so much for your help!
-
05-05-2008, 09:05 AM #12WHT Addict
- Join Date
- Sep 2006
- Location
- Indiana
- Posts
- 167
Probably is this line:
Code:orseof.movefirst
It can be omitted safely, as you open the recordset on the line above it. Recordsets open at the first record, so moving to the first is actually unnecessary.[Lurking Glass] <- Not a webhost.
-
05-05-2008, 09:20 AM #13New Member
- Join Date
- May 2008
- Posts
- 2
perfect, thank you!
-
05-05-2008, 09:44 AM #14New Member
- Join Date
- May 2008
- Posts
- 2
okay, new problem (should i make a new thread?) but a similar one.
i am getting;
Code:Microsoft OLE DB Provider for ODBC Drivers error '80040e07' [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. /cwk/customer_orderproduct.asp, line 19
Code:<!--#include file="logon.inc"--> <% If Session("Email") = "" then Response.Redirect "login.asp" End if productid = request.form("productid") quantity = request.form("quantity") orderid = request.form("orderid") dim orseof set db=server.createobject("adodb.connection") set orseof=server.createobject("adodb.recordset") db.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("joannemahoney.mdb") strsql = "INSERT INTO tblOrderitems" strsql = strsql+"(orderid,productid,quantity)Values" strsql = strsql+"('"&orderid&"','"&productid&"','"&quantity&"')" orseof.open strsql,db dim orseof2 set db=server.createobject("adodb.connection") set orseof2=server.createobject("adodb.recordset") db.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("joannemahoney.mdb") strsql = "SELECT price FROM tblproduct WHERE productid = "&productid&" " orseof2.open strsql,db orseof2.movefirst price = orseof2("price") dim orseof3 set orseof3=server.createobject("adodb.recordset") qrySQL = "SELECT subtotal FROM tblorder WHERE orderid = "&orderid&" " orseof3.open qrySQL,db orseof3.movefirst subtotal = orseof3("subtotal") subtotal = subtotal + price*quantity dim orseof4 set db=server.createobject("adodb.connection") set orseof4=server.createobject("adodb.recordset") db.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("joannemahoney.mdb") qrsql = "UPDATE tblOrder set subtotal='"&subtotal&"' where orderid="&orderid&"; " set orseof4=db.Execute (qrSql) response.redirect "customer_order1.asp?0rderid="&orderid&"" %>
Help please!
-
05-05-2008, 10:29 AM #15WHT Addict
- Join Date
- Sep 2006
- Location
- Indiana
- Posts
- 167
Code:strsql = strsql+"('"&orderid&"','"&productid&"','"&quantity&"')"
Try:
Code:strsql = strsql+"("&orderid&","&productid&","&quantity&")"
[Lurking Glass] <- Not a webhost.
-
05-05-2008, 11:06 AM #16New Member
- Join Date
- May 2008
- Posts
- 2
I tried that already, I recieved a formatting error. I'll try again and write the result for you.
-
05-05-2008, 11:10 AM #17New Member
- Join Date
- May 2008
- Posts
- 2
Code:Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. /cwk/customer_orderproduct.asp, line 19
-
05-05-2008, 11:18 AM #18WHT Addict
- Join Date
- Sep 2006
- Location
- Indiana
- Posts
- 167
Oh, didn't notice this before. But there are no spaces around the things in the INSERT statement. Try adding spaces around the "VALUES" keyword, and the column name and column value sets that are in parentheses. Basically, don't let any parts of the statement touch. Extra spaces are okay.
[Lurking Glass] <- Not a webhost.
-
05-05-2008, 11:22 AM #19New Member
- Join Date
- May 2008
- Posts
- 2
Same error with this:
Code:strsql = "INSERT INTO tblOrderItems" strsql = strsql+"( orderid , productid , quantity ) Values " strsql = strsql+"( "&orderid&" , "&productid&" , "&quantity&" ) " orseof.open strsql,db
-
05-05-2008, 11:23 AM #20New Member
- Join Date
- May 2008
- Posts
- 2
And same error with;
Code:strsql = "INSERT INTO tblOrderItems" strsql = strsql + " ( orderid , productid , quantity ) Values " strsql = strsql + " ( "&orderid&" , "&productid&" , "&quantity&" ) " orseof.open strsql,db
-
05-05-2008, 11:31 AM #21WHT Addict
- Join Date
- Sep 2006
- Location
- Indiana
- Posts
- 167
Hm, maybe it's something to do with trying to get a recordset out of an insert statement. I haven't been looking at this real close, as I haven't had time, but try this.
Replace:
orseof.open strsql,db
With:
db.Execute(strsql)
Oh, and change the "+" symbols to "&".
Actually, come to think of it...it's more likely that later that is causing the issues.[Lurking Glass] <- Not a webhost.
-
05-05-2008, 11:35 AM #22New Member
- Join Date
- May 2008
- Posts
- 2
It didn't seem to want to respond to any combination of those changes, I tried both db str commands with both + and & and get the same error each time!
-
05-05-2008, 11:38 AM #23WHT Addict
- Join Date
- Sep 2006
- Location
- Indiana
- Posts
- 167
Hmmm.
Are any of the database fields "AutoNumbers"? Any of the inserted values NULL or empty strings?
What is the error it gives now that all the changes have been made?[Lurking Glass] <- Not a webhost.
-
05-05-2008, 11:52 AM #24New Member
- Join Date
- May 2008
- Posts
- 2
Error is exactly the same as before;
Code:Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. /cwk/customer_orderproduct.asp, line 19
ASP is annoying
-
05-05-2008, 11:55 AM #25WHT Addict
- Join Date
- Sep 2006
- Location
- Indiana
- Posts
- 167
Try this, add the following lines before you execute/open the statement.
Response.Write(strsql)
Response.End
That'll spit out whatever the SQL string holds...and may give some insight as to what is going on. After doing that, post the result here, and I'll see if it looks to be problematic.[Lurking Glass] <- Not a webhost.