Change Sql-Statement In .net Sdk 关注


Hi folks,

after years of using Bartender with COM, I try to upgrade my programs to .NET SDK (C#). I have a (maybe) simple question.
I have to change the SQL-Statement before printing. In COM I did a simple: BTFormat.InputDataFileSetup.OLEDB.SQLStatement = SQLCommand;
But I have not find a possibility to change the SQL-String in .NET SDK.

I will be thankful for any suggestions !!

Best regards from germany

1 评论

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


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