我正在尝试使用 IfxCommand 执行一个简单的选择查询。我想将隔离设置为脏读,但我只找到了在 IfxTransaction 的上下文中设置隔离级别的示例。我不需要事务,因为我只发出一个选择语句。以下是我当前的代码,这是最好的方法吗?另外,如果您知道隔离级别设置为脏读多长时间,我想知道。
DataSet ds = new DataSet();
IfxConnection connection = new IfxConnection(ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString);
IfxCommand command = new IfxCommand();
try
{
connection.Open();
command.Connection = connection;
command.CommandText = "SET ISOLATION TO DIRTY READ";
command.ExecuteNonQuery();
command.CommandText = BuildCommandString();
IfxDataAdapter idap = new IfxDataAdapter(command.CommandText, connection);
idap.Fill(ds);
}