跳到主内容

搜索

搜索

Can I Use Two Databases Independently Without Joining?

评论

2 条评论

  • Avatar
    Ian Cummings
    版主

    Unfortunately, currently we only support related tables/databases in the main database connection configuration for a BarTender document.

     

    However, it sounds like you just need to configure a database look-up for this item.  This can be achieve through the use of a VB script for the source of the form field instead of embedded data.  Here is an example of the code you would use to populate a list control in the BarTender data entry form from an Excel file.

     

    *Note that you'll need to change folder/file/sheet/field names for your own purposes.

     

     
    Functions and Subs
     
    dim objConn
    dim strConn
    dim rs
     
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\items and item numbers.xls';Extended Properties=""Excel 8.0;HDR=YES;"""
     
    Public Function GetNames()
        Dim strNames
     
        Set objConn = CreateObject("ADODB.Connection")
        objConn.Open strConn
        Set rs = CreateObject("ADODB.Recordset")
        Set rs = objConn.Execute("SELECT * FROM [Sheet1$]")
     
        strNames = ""
        rs.MoveFirst()
        do while NOT rs.EOF
            strNames = strNames + rs.fields("Item") + vbCrLf
            rs.MoveNext()
        loop
     
        GetNames = strNames
     
    End Function
     
     
    OnFillList
     
    Value = GetNames()
    0
  • Avatar
    Legacy Poster

    I am in a similar situation, but retrieving records from a SQL Server database using a System DSN.    The query is working correctly when i run it directly against the database, so there must be an issue somewhere else.  Any ideas what the issue is?

     

     

    'Connect to the system DSN
    Value = Value


    Dim conn
    Set conn = CreateObject("ADODB.Connection")
    conn.open "IMFTest905", "Corp\svc_epicor", "Norgren01"


    'get the view with usercode values that we need
    Dim strSQL
    strSQL = "select Number01 from v_labelcodes where v_labelcodes.CodeTypeID = 'ARTPAM' AND v_labelcodes.CodeID = 'F'"
    Dim rs
    Set rs = CreateObject("ADODB.Recordset")
    rs.Open strSQL, conn

     

    'make sure we have one record, and if so, set the value to Number01
    if rs.RecordCount = 1 then
     Value = rs("Number01")
    else
     Value = Value
    end if

     

    'close the connection, clean up
    conn.close
    set conn = Nothing

    0

请先登录再写评论。