Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need to check item numbers against database

    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


    Code:
    <%
    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
    %>
    Last edited by misterzr; 06-03-2005 at 05:28 AM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •