Skip to main content

ODBCQuery

Suggest edit Updated on November 10, 2021

Use the ODBCQuery when connecting to an ODBC provider. ODBC (Open Database Connectivity) is a standard software API designed to connect to database management systems. It is designed to be independent of any specific language or operating system.

The Query components return a dataset or execute a command (such as insert or update). If the query returns data, the dataset is created as part of the Query component. You can display the returned data by either connecting the Query GetTable method or by specifying the query as the provider for a TableView and then binding the TableView to a visible component (such as a DataGrid or ListBox) by using the DataSource property of the control.

The Connection String property provides access to the Microsoft Data Link Properties window. Use this series of dialogs to identify the data source and create a connection string. The ODBCQuery wraps .NET’s ODBCConnection component.

When you add this component to an automation, the system places it in the Global tab of the component tray. For more information, see Adding Global Components to an Automation. This component must be global to be referenced by other automations in the project.

ODBCQuery properties

PropertyDescription
CommandText

The SQL statement.

Use the question mark (?) for parameters in the statement. For example: SQL: Select CustomerID, CompanyName, ContactName, Country, Region FROM Customers WHERE Country = ?

Note: Do not dynamically change the CommandText if there are parameters in the command.

CommandTimeout The amount of time you want the solution to wait to execute the query. The default is 30 seconds.
CommandType

Specifies how the CommandText is interpreted.

  • Use Text when the Command Text is a SQL Select statement.
  • Use StoredProcedure when the Command Text is the name of a stored procedure.
  • Use TableDirect when the CommandText is the name of a table.
ConnectionStringThe string used to open the data source. To create the Connection String, browse this property to open the Microsoft Data Link Properties window. Click the Help button on this dialog for more information. Here is an example of a database connection:
Data link properties

These settings create this connection string: Dsn=MS Sql Server;persist security info=False;uid=User

Parameters

Browse this property to open the OdbcParameter Collection Editor dialog and set default values for parameters used in the CommandText. An example of this dialog is shown below.

Note that you must test the query for the query parameters to be fully defined in the project. If you run the project without testing the query in Studio, an error is thrown. Click the Test Query link to test the query with the parameters.

Note: The size of the parameter you enter when you test the query sets the allowable runtime size limit.

ODBC parameter
ReturnTypeIndicates if the query will return rows of data, a scalar value or no data at all.

ODBCQuery methods

MethodDescriptionParametersReturn Type
ExecuteRuns the SQL statement against the designated datasource. As specified in the SQL statementVoid
GetTableUse this method to return a data table containing the query data. NoneDataTable
Did you find this content helpful? YesNo

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us