Quantcast
Channel: Classic ASP
Viewing all articles
Browse latest Browse all 488

Query doesn't work the same in an ASP page

$
0
0

Hi All,

I have an Access database that has a history table which I'm trying to show all records in each box based on a number input. So if I entered for example 45001 that box number has 14 boxes. 45001-1, 45001-2, 45001-3 etc. So in my search I want to be able to select a dropdown with 45001 and the result would show me the results in chronological order as in:

 

CGBoxScanCode
45001-3
45001-4
45001-7
45001-8
45001-11
45001-13
45001-14

When I use the following SQL 

SELECT CGBoxScanCode
FROM (SELECT DISTINCT CGBoxScanCode FROM CGBoxStatusIn_history
WHERE CGBoxScanCode Like MMColParam & "*") 
ORDER BY Left([CGBoxScanCode],InStr([CGBoxScanCode],"-")-1), CLng(Mid([CGBoxScanCode],InStr([CGBoxScanCode],"-")+1));

it works in a query in Access however when I use it in a recordset :

<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_manpower_STRING
Recordset1_cmd.CommandText = "SELECT CGBoxScanCode FROM( SELECT DISTINCT CGBoxScanCode FROM CGBoxStatusIn_history) WHERE CGBoxScanCode Like ? & "*" ORDER BY Left([CGBoxScanCode],InStr([CGBoxScanCode],"-")-1), CLng(Mid([CGBoxScanCode],InStr([CGBoxScanCode],"-")+1));" 
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 200, 1, 255, Recordset1__MMColParam) ' adVarChar

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>

it doesn't work.....can anyone tell me what's wrong here?

Thanks in Advance,

Lenny


Viewing all articles
Browse latest Browse all 488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>