Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
asp multiple selection boxe - please help
Old 12-02-2008, 03:50 PM asp multiple selection boxe - please help
tadisaus2's Avatar
Skilled Talker

Posts: 89
Trades: 0
Hello,
Can anyone please help me on multiple selection box?
I have this table:
Cars Date-Sold Sellers
--- --------- -------
A 02/09/2008 aa
B 3/08/2008 bb
C 8/02/2008 aa
B 9/04/2008 cc
A 11/02/2008 bb
A 10/04/2008 cc
I tried to create a INSERT page that uses the data from an existing table for selection boxes:
1. When a user select "Cars type"
2. Date sold and shipped will show up based on "cars type" selected
3. When Date sold/shipped was selected, Seller's names will show up based on "date sold/shiped" selected

I keep getting this error below. I already turned on the friendly errors url.
Can you please help?
Thanks you so much!

Technical Information (for support personnel)
Error Type:
Microsoft JET Database Engine (0x80040E07)
Data type mismatch in criteria expression.
/tran/selectcombo2.asp, line 63

Page:
POST 43 bytes to /tran/selectcombo2.asp
POST Data:
cars=1&dateSold=1%2F6%2F2008+-+2%2F9%2F2008
Time:
Monday, December 01, 2008, 10:18:57 AM
-----------------------------------------------------

<b>Select a car type to view dates sold</b>
<br><bR>
<form name="frmSelect" method="Post" action="selectcombo2.asp">
<fieldset>
Select Car Type :
<% Set oRs=Server.CreateObject("adodb.recordset")
strSQL = "SELECT DISTINCT Cars FROM tblComboSelect ORDER BY Cars;"
oRs.Open strSQL, conn
if not oRs.eof then %>
<SELECT name="cars" onChange="Javascript:frmSelect.submit();">
<OPTION VALUE = "1" >
<% do until oRs.EOF %>

<OPTION VALUE="<%= oRS(0) %>" <% if trim(request.form("Cars")) = trim(oRS(0)) then response.write " selected " end if %>><%= oRS(0) %></option>
<% oRs.MoveNext
loop %>
</SELECT>
<% else %>
<i>No cars found in the database</i>
<% end if %>
<br />
Date(s) Shipped and Sold :
<% if trim(request.form("Cars")) <> "" then
'user has selected a car therefore show dates select box
strSQL = "SELECT DateShippedIn, DateSold FROM tblComboSelect WHERE Cars='" & trim(request.form("Cars")) & "';"
Set oRs=Server.CreateObject("adodb.recordset")
oRs.Open strSQL, conn
if not oRs.eof then %>
<select name="dateSold">
<% do until oRs.eof %>
<option value="<%= ors("DateShippedIn") %> - <%= ors("DateSold") %>"><%= ors("DateShippedIn") %> - <%= ors("DateSold") %></option>
<% oRs.MoveNext
loop %>
</select>
<% else %>
<i>No records found for that car</i>
<% end if
else
'user has not selected a car therefore do not show date select box
response.write "<i>No car selected yet</i>"
end if %>
</fieldset>

<br />
Sellers :
<% if trim(request.form("dateSold")) <> "" then
strSQL = "SELECT sellerLast, sellerFirst FROM tblComboSelect WHERE DateSold='" & trim(request.form("DateSold")) & "' AND DateShippedIn='" & trim(request.form("DateShippedIn")) & "';"
Set oRs=Server.CreateObject("adodb.recordset")
oRs.Open strSQL, conn
if not oRs.eof then %>
<select name="dateSold">
<% do until oRs.eof %>
<option value="<%= ors("sellerLast") %>, <%= ors("sellerFirst") %>"><%= ors("sellerLast") %>, <%= ors("sellerFirst") %></option>
<% oRs.MoveNext
loop %>
</select>
<% else %>
<i>No records found for that car</i>
<% end if
else
'user has not selected a car therefore do not show date select box
response.write "<i>No car selected yet</i>"
end if %>
</fieldset>
</form>

Thanks.
tadisaus2 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-02-2008, 05:23 PM Re: asp multiple selection boxe - please help
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Use the CheckBoxList control.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 12-05-2008, 02:21 PM Re: asp multiple selection boxe - please help
$100 - $999 Monthly

Posts: 30
Trades: 0
Two things.

First, the error "Data type mismatch in criteria expression" means that one of your SQL queries is syntactically incorrect.
To debug it, try to Response.Write your queries before executing them. You will see the error.
Second, never use string concatenation for your queries... You site will not last even 15 minutes, as someone will run a sql injection code on it. Instead, use command parameters.
Third... try asp.net rather than asp. You will be able to step through the code, this makes debugging very easy. It is also much faster than asp.

Regards.
dealsguy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to asp multiple selection boxe - please help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12389 seconds with 12 queries