Executes the SQL statement (
TdCommand.CommandText property) using one of the
Data.CommandBehavior values.
Parameters
- behavior
- One of the Data.CommandBehavior enumerations values. Used to ask for inline LOBs or to close the connection after DataReader is closed.
Return Value
Returns a TdDataReader object
The following example creates a
TdConnection
and executes a SQL statement. It returns a
TdDataReader
. When the calling method closes the
TdDataReader
, the corresponding
TdConnection
is closed.
public TdDataReader ExecuteQuery(string connectionString, string commandText)
{
TdConnection cn = new TdConnection(connectionString);
cn.Open();
TdCommand cmd = new TdCommand(commandText, cn);
TdDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
return reader;
}
Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019