Labelformat.databaseconnections Follow

0
Avatar
Legacy Poster

When I do this:

 

PrintLabelFormatTask printTask = new PrintLabelFormatTask("myformat.btw");
 
Then printTask.LabelFormat.DatabaseConnections doesn't have anything loaded even though it's been configured in myformat.btw. I need access to the text file database that's configured so that I can change the filename to read from a temp file.
 

2 comments

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

Here is an example of setting the text file to use as the database connection in C#.

 

public void Demo()
{
   // Initialize a new BarTender print engine. 
   using (Engine btEngine = new Engine())
   {
      // Start the BarTender print engine.
      btEngine.Start();

      // Create an instance of TextFile 
      TextFile textFile = new TextFile("TextfileDatabase");

      // Provide a path to the text file.
      textFile.FileName = @"C:\TextfileDatabase.txt";

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

      // Set the database connection created above.
      btFormat.DatabaseConnections.SetDatabaseConnection(textFile);

      // Print the format.
      btFormat.Print();

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

      // Stop the BarTender print engine.
      btEngine.Stop();
   }
}
0
Avatar
Legacy Poster
Comment actions Permalink

I've tried that, but I'm trying to make a web based printing app.  I'd like to use the TaskManager to manage engines so that I don't have to make up my own.  Also, I couldn't get any error events to fire when printing doesn't work. All the events seem to work much better when using TaskManager.

Please sign in to leave a comment.