Jump to content
Sign in to follow this  
KenNichols

SQL Join Question

Recommended Posts

KenNichols

With the following query the "Item_Desc1" doesn't match the correct "Item_ID". What am I doing wrong?

#Include <Array.au3>

$WHID = InputBox("Input Warehouse Number","Input Warehouse Number", "3009")

$sqlCon = ObjCreate("ADODB.Connection")
$sqlCon.Open("Driver={SQL Server};SERVER=Test;DATABASE=Test;UID=;PWD=;")
;==================================================Part Number
Dim $PartNumber[1][3]
;$query = "SELECT ItemWH.Item_ID FROM Item JOIN ItemWH ON Item.Item_ID=ItemWH.Item_ID Where WH_ID = '" & $WHID & "'"
$query = "SELECT ItemWH.Item_ID FROM Item JOIN ItemWH ON Item.Item_ID=ItemWH.Item_ID Where WH_ID = '" & $WHID & "' AND ItemWH_OnHand<>0"
        $rs = $sqlCon.EXECUTE($query)
        With $rs
            While Not .EOF
                ReDim $PartNumber[UBound($PartNumber, 1) + 1][3]
                $PartNumber[UBound($PartNumber, 1) - 1][0] = .Fields (0).value
                .MoveNext
            WEnd
        EndWith
        $PartNumber[0][0] = "Part Number"
;==================================================Part Desc
;$query = "SELECT Item_Desc1 FROM Item JOIN ItemWH ON Item.Item_ID=ItemWH.Item_ID Where WH_ID = '" & $WHID & "'"
$query = "SELECT Item.Item_Desc1 FROM Item JOIN ItemWH ON Item.Item_ID=ItemWH.Item_ID Where ItemWH.WH_ID = '" & $WHID & "' AND ItemWH_OnHand<>0"
        $rs = $sqlCon.EXECUTE($query)
        With $rs
            While Not .EOF
                For $i = 1 To UBound($PartNumber) -1 ;Step +1
                $PartNumber[$i][1] = " " & .Fields (0).value
                .MoveNext
                Next
            WEnd
        EndWith
        $PartNumber[0][1] = "Part Description"
;==================================================Qty OnHand
;$query = "SELECT ItemWH_OnHand FROM Item JOIN ItemWH ON Item.Item_ID=ItemWH.Item_ID Where WH_ID = '" & $WHID & "'"
$query = "SELECT ItemWH_OnHand FROM Item JOIN ItemWH ON Item.Item_ID=ItemWH.Item_ID Where WH_ID = '" & $WHID & "' AND ItemWH_OnHand<>0"
        $rs = $sqlCon.EXECUTE($query)
        With $rs
            While Not .EOF
                For $i = 1 To UBound($PartNumber) -1 ;Step +1
                $PartNumber[$i][2] = .Fields (0).value
                .MoveNext
                Next
            WEnd
        EndWith
        $PartNumber[0][2] = "Qty OnHand"
;==================================================
$sqlCon.close
ReDim $PartNumber[UBound($PartNumber, 1) - 1][3]
_ArrayDisplay($PartNumber)
Edited by KenNichols

[topic="21048"]New to AutoIt? Check out AutoIt 1-2-3![/topic] Need to make a GUI? You NEED KODA FormDesigner!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.