Reputation: 9
I am using ADODB interop DLL Version :6.0.0.0 to connect any type of database.
CommandTimeout is 3 seconds Opening the recordset with command object with timeout of 3 seconds.
With Oracle database with huge data, when I enter select query, itdoes not time out.
How to timeout the executing query?
I have tried to set command timeout to 1 second as well but still its not getting timed out.
Set connection timeout to be 3 seconds (I know this is different than command time out but still tried)
**In MSSQl database, in stored proc if i insert 10 lack records and have select query after that, it actually gives timeout while executing the proc, but if I have only the select query in proc as well, it will not time out.
public DataTable ExecuteQuery(string commandText, int timeout = 3) {
if (connection.State.Equals(connected))
{
var command = createCommand(commandText, CommandTypeEnum.adCmdText, 3);
var recordset = createRecordset(); recordset.Open(command);
command = null; return dataTable;
} }
private Command createCommand(string commandText, CommandTypeEnum commandType, int timeout = 3) {
var command = new ADODB.Command
{
ActiveConnection = connection,
CommandText = commandText,
CommandType = commandType,
CommandTimeout = timeout
};
return command; }
private Recordset createRecordset() {
return new Recordset
{
CursorType = CursorTypeEnum.adOpenStatic,
CursorLocation = CursorLocationEnum.adUseClient,
LockType = LockTypeEnum.adLockReadOnly,
}; }
I expect to have error of timed out when query executes more than 3 seconds.
Upvotes: 0
Views: 252