Zum Hauptinhalt gehen

Suche

Suche

Access Database Data Source

Kommentare

4 Kommentare

  • Avatar
    Legacy Poster

    I think I may have found the solution to this if I can do it by creating an OLEdb connection and passing it to the bartender format with this: btFormat.DatabaseConnections.SetDatabaseConnection(<database file>)

     

    similar to what is in the documentation below:

     

    Public Sub Demo()
       ' Initialize a new BarTender print engine.
       Using btEngine As New Engine()
          ' Start the BarTender print engine.
          btEngine.Start()

          ' Create an OLEDB object to define a database connection.
          Dim oledb As New OLEDB("<database file>")

          ' Set the user ID and password for the connection.
          oledb.UserID = "Admin"
          oledb.SetPassword("newpassword")

          ' Initialize the format document
          ' (create a format with query prompts to use this example).
          Dim btFormat As LabelFormatDocument = btEngine.Documents.Open("C:\FormatWithQueryPrompts.btw")

          ' Set the database connection.
          btFormat.DatabaseConnections.SetDatabaseConnection(<database file>)

          ' Print the format.
          btFormat.Print()

          ' Close the current format without saving.
          btFormat.Close(SaveOptions.DoNotSaveChanges)

          ' Stop the BarTender print engine.
          btEngine.Stop()
       End Using
    End Sub

     

     

    I will post a reply if this works, I need to make a program split as we have a production copy currently because I went with the cumbersome workaround for now.

    0
  • Avatar
    Ian Cummings
    Moderator

    Sorry, but it is not possible to change the database source via automation, only to specify queries etc.  I believe you will need to go via the multiple BarTender documents route.

     

    How did you get on with your possible solution?

    0
  • Avatar
    Legacy Poster

    We ended up using multiple bartender files. it seems to not be too big of an issue/time sink to do it that way so it is working quite well. The only issue I have currently with the entire system is that sometimes the bartender query print job will all of a sudden take 6+ seconds to run compared to a consistent half second. It might be outside processes causing this issue, I haven't been able to put my finger on it.

    0
  • Avatar
    Legacy Poster

    Due to issues querying the access data files from across the network we were getting the random slow prints. Since I can't 'programmatically' change the database source file location to a local folder after copying the .accdb file to a local temp folder I had to go a completely different route. I switched to using SQL, importing the access database files into SQL tables I then use an ODBC File DSN trick to make the bartender file look at the 'local' SQL instance instead of the network SQL instance the label was created from. when the data prep users create the label files they use a file DSN named ScanAndPrint that points to the Master SQL database on the network and an SSIS package replicates the data from the Master SQL database out to each of the production machines. Each one of those machines has the same DSN named ScanAndPrint except theirs points to the (local) database instead of the master. I have officially 'tricked' Bartender.

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.