Skip to main content



Change Sql-Statement In .net Sdk


1 comment

  • Avatar
    Ian Cummings

    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 =
    ((OLEDB)btFormat.DatabaseConnections[0]).SQLStatement = SQL;


    In VB:

    Dim SQL As
    String = "SELECT `Calories` FROM
    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.


Please sign in to leave a comment.