ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old February 2nd, 2000, 09:07 PM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,578 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
ASP Search w/ Access Database

<i><b>Originally posted by : Craig Brown (cbrown@madcityautos.com)</b></i><br /><br />I am learning ASP and have what is probably a very simple problem... I am creating a search page that passes a number in the query string, pulls the results out of an Access database and displays them on the results page. My problem is that the when numbered value I pass, (strSalePrice), in my query string is set as a 'number' in Access, I get an error from the results page, "Data type mismatch in criteria expression". This error does not happen when the Access field is set to 'text'. Any help on this would be appreciated!! Thanks! <br /><br />Below is my code...<br /><br />______________________<br />Search Page<br /><br />if not isempty(Request.Form("Search")) then<br /> strType = "AutoType=" & Request.Form("AutoType") & "&"<br /> strYear = "Year=" & Request.Form("Year") & "&"<br /> strSalePrice = "SalePrice=" & Request.Form("SalePrice") & "&"<br /> strOrderBy = "OrderBy=" & Request.Form("OrderBy")<br /> strQ = strType & strYear & strSalePrice & strOrderBy<br /> Response.Redirect "./get-results.asp?" & strQ<br /> end if<br /><br />_____________________<br />Results Page<br /><br />set conn = Server.CreateObject ("adodb.connection")<br /> conn.open "MadCityAutos", "sa", "password"<br /> strOrderBy = "ORDER by " & Request.QueryString("OrderBy") & " DESC"<br /> set RSAutos = conn.execute("SELECT * FROM main where " _<br /> & "AutoType = '" & Request.QueryString("AutoType") & "' and " _<br /> & "Year >= '" & Request.QueryString("Year") & "' and " _<br /> & "SalePrice <= '" & Request.QueryString("SalePrice") & "' ORDER by SalePrice DESC")<br /><br />

Reply With Quote
  #2  
Old February 2nd, 2000, 11:20 PM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,578 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
<i><b>Originally posted by : steve schofield</b></i><br />Your context is just fine except when passing numbers to the database either lose the single quotes around the data that is passed to the db. <br />hope this helps<br /><br />steve<br /><br />here is your code minus the single quotes around the strSalePrice data.<br /><br />set conn = Server.CreateObject ("adodb.connection")<br />conn.open "MadCityAutos", "sa", "password"<br />strOrderBy = "ORDER by " & Request.QueryString("OrderBy") & " DESC"<br />set RSAutos = conn.execute("SELECT * FROM main where " _<br />& "AutoType = '" & Request.QueryString("AutoType") & "' and " _<br />& "Year >= '" & Request.QueryString("Year") & "' and " _<br />& "SalePrice <= " & Request.QueryString("SalePrice") & " ORDER by SalePrice DESC")<br /><br /><br />------------<br />Craig Brown at 2/2/00 7:07:18 PM<br /><br /><br />I am learning ASP and have what is probably a very simple problem... I am creating a search page that passes a number in the query string, pulls the results out of an Access database and displays them on the results page. My problem is that the when numbered value I pass, (strSalePrice), in my query string is set as a 'number' in Access, I get an error from the results page, "Data type mismatch in criteria expression". This error does not happen when the Access field is set to 'text'. Any help on this would be appreciated!! Thanks! <br /><br />Below is my code...<br /><br />______________________<br />Search Page<br /><br />if not isempty(Request.Form("Search")) then<br /> strType = "AutoType=" & Request.Form("AutoType") & "&"<br /> strYear = "Year=" & Request.Form("Year") & "&"<br /> strSalePrice = "SalePrice=" & Request.Form("SalePrice") & "&"<br /> strOrderBy = "OrderBy=" & Request.Form("OrderBy")<br /> strQ = strType & strYear & strSalePrice & strOrderBy<br /> Response.Redirect "./get-results.asp?" & strQ<br /> end if<br /><br />_____________________<br />Results Page<br /><br />set conn = Server.CreateObject ("adodb.connection")<br /> conn.open "MadCityAutos", "sa", "password"<br /> strOrderBy = "ORDER by " & Request.QueryString("OrderBy") & " DESC"<br /> set RSAutos = conn.execute("SELECT * FROM main where " _<br /> & "AutoType = '" & Request.QueryString("AutoType") & "' and " _<br /> & "Year >= '" & Request.QueryString("Year") & "' and " _<br /> & "SalePrice <= '" & Request.QueryString("SalePrice") & "' ORDER by SalePrice DESC")<br /><br />

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > ASP Search w/ Access Database


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway