Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21842

VB 6.0 Executing SQL with Inter Join

$
0
0
Hello, I am new to VB, but I am trying to add an inter join in the below sqlBO statement. The inter join is from a table in an access database where I opened a new connection called distConn.

The below code debugs on the line rstBO.Open sqlBO, cnnBO, adOpenDynamic. I belive it is debugging becasue it can not find tblBoMonth in cnnBO, because tblBOMonth is in an access database with distConn.

The sql statement runs fine if I remove the inter join code: INNER JOIN tblBoMonth ON BO_PRIORITY_MONTH = tblBoMonth.BO_Month

Can anyone suggest how i can make this work with the inter join code?

Thank you!


Code:


  'open BO
  cnnBO.Open "DSN=ASUSERLIB;UID=XXXX;PWD=XXXX;"
  cnnBO.CommandTimeout = 0
 
 
  ' open connection to distribution system to ge back order months

  Set distConn = New ADODB.Connection
  distConn.CursorLocation = adUseClient
  distConn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & distPath & ";"

 
 
  'process infile
  With rstInFile
    Do Until .EOF
     
      'get new priority code - if we are changing warehouse
      If sWarehouse <> .Fields("Warehouse").Value Then
        iNewPriority = CInt(sGetNewPriorityCode(.Fields("Warehouse").Value))
        sWarehouse = .Fields("Warehouse").Value
      End If
     
      'retrieve BO for this model/spec/color
      staBar.Panels(1).Text = "Processing " & .Fields("Model").Value & " " & .Fields("Spec").Value & " " & .Fields("Color").Value
      sqlBO = "SELECT COMPANY_CODE, PRODUCT_TYPE, DLR_NO, SO_NO, BO_PRIORITY_MONTH, BO_PRIORITY, MODEL_NO, SPEC_CODE, COLOR_CODE, CASE WHEN BO_PRIORITY_MONTH < '09' THEN CONCAT('1', BO_PRIORITY_MONTH) ELSE CONCAT('0', BO_PRIORITY_MONTH) END AS SortMonth " & _
            "FROM SOVSCA102 INNER JOIN tblBoMonth ON BO_PRIORITY_MONTH = tblBoMonth.BO_Month " & _
            "WHERE SO_STATUS_CODE='2' AND MODEL_NO = '" & .Fields("Model").Value & "' AND COLOR_CODE = '" & .Fields("Color").Value & "' AND BO_PRIORITY > '4' AND BO_PRIORITY < '9'" & _
            "ORDER BY SortMonth ASC"
      rstBO.Open sqlBO, cnnBO, adOpenDynamic


Viewing all articles
Browse latest Browse all 21842

Trending Articles



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