Skip to main content

Search

Search

Change Sql-Statement In .net Sdk

Comments

1 comment

  • Avatar
    Ian Cummings
    Moderator

    I copied this from BarTender's "Automating BarTender>Automation with BarTender .NET SDKs>BarTender .NET Print SDK>Getting Started>How To: Automate Database Printing" help topic:

     

     

    Changing the OLE DB/ODBC SQL Statement

    When using an OLE DB or ODBC database connection, custom SQL statements may be used to perform record filtering when data browsing or to select database records at print time. To apply custom SQL statements, use the SQLStatement property.


    The following code demonstrates how to set a custom SQL statement when using an OLE DB database connection.


    In C#:


    string SQL = "SELECT `Calories` FROM `NutritionInformation`";
    Engine btEngine = new Engine();
    
    LabelFormatDocument btFormat =
    btEngine.Documents.Open(@"C:\NutritionLabel.btw");
    
    ((OLEDB)btFormat.DatabaseConnections[0]).SQLStatement = SQL;
    

     

    In VB:


    Dim SQL As
    String = "SELECT `Calories` FROM
    `NutritionInformation`"
    Dim btEngine As
    New Engine()
    
    Dim btFormat As LabelFormatDocument = btEngine.Documents.Open("C:\NutritionLabel.btw")
    
    CType(btFormat.DatabaseConnections(0), OLEDB).SQLStatement
    = SQL
    

     

    By setting this property, the custom SQL statement will be used rather than the SQL statement set inside of BarTender.

    0

Please sign in to leave a comment.