...

View Full Version : Need to check item numbers against database



misterzr
06-03-2005, 05:06 AM
I need to validate an item number from a form field against a MS SQL database. Would like to do it with onchange.

I am using a 2 page process to print barcodes from an entered item number on page 1 and need to only use valid item numbers from the database. If they enter a wrong number I want to give them a page telling them of the error. I have 32 fields on page 1 to enter 32 items.(one for every label on the second page that contains the barcodes. Here is the connection to the database that I am using for the barcode.(Column IMLITM contains the item numbers)

This should be easy but I can't get my head around it



<%
Dim rsBarcode1
Dim rsBarcode1_numRows
Set rsBarcode1 = Server.CreateObject("ADODB.Recordset")
rsBarcode1.ActiveConnection = MM_JDE_DEV_STRING
rsBarcode1.Source = "SELECT 'bcUPCE' AS type, SUBSTRING(IMAITM, 7, 8) AS barcodevalue FROM TESTDTA.F4101 WHERE (LEFT(IMAITM, 6) = '000000') and IMLITM='" + Replace(rsBarcode1__MMColParam, "'", "''") + "' UNION SELECT 'bcUPCA' AS type, SUBSTRING(IMAITM, 3, 12) AS barcodevalue FROM TESTDTA.F4101 WHERE (LEFT(IMAITM, 2) = '00') AND LEFT(IMAITM, 6) <> '000000' AND RIGHT(IMAITM, 1) < '0' and IMLITM='" + Replace(rsBarcode1__MMColParam, "'", "''") + "' UNION SELECT 'bcEAN13' AS type, SUBSTRING(IMAITM, 2, 13) AS barcodevalue FROM TESTDTA.F4101 WHERE (LEFT(IMAITM, 1) = '0') AND (LEFT(IMAITM, 2) <> '00') and IMLITM='" + Replace(rsBarcode1__MMColParam, "'", "''") + "' UNION SELECT 'bc2OF5' AS type, SUBSTRING(IMAITM, 1, 14) AS barcodevalue FROM TESTDTA.F4101 WHERE LEN (IMAITM)=14 and (LEFT(IMAITM,3 ) = '100') and IMLITM='" + Replace(rsBarcode1__MMColParam, "'", "''") + "' or LEN (IMAITM)=14 and (LEFT(IMAITM,3 ) = '200') and IMLITM='" + Replace(rsBarcode1__MMColParam, "'", "''") + "' or LEN (IMAITM)=14 and (LEFT(IMAITM,3 ) = '300') and IMLITM='" + Replace(rsBarcode1__MMColParam, "'", "''") + "' UNION SELECT 'bc3OF9' AS type, SUBSTRING(IMAITM, 3, 12) AS barcodevalue FROM TESTDTA.F4101 WHERE IMAITM LIKE '%[A-W]%' and IMLITM='" + Replace(rsBarcode1__MMColParam, "'", "''") + "' UNION SELECT 'bc3OF9' AS type, SUBSTRING(IMAITM, 10, 4) AS barcodevalue FROM TESTDTA.F4101 WHERE (LEFT(IMAITM, 9) = '000000000') AND IMAITM LIKE '_____________0' and IMSRP1 <> 'NAR' and IMLITM='" + Replace(rsBarcode1__MMColParam, "'", "''") + "' "
rsBarcode1.CursorType = 0
rsBarcode1.CursorLocation = 2
rsBarcode1.LockType = 1
rsBarcode1.Open()
rsBarcode1_numRows = 0
%>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum