- GetOutputParameters ();
- ( (SqlAsyncResult) ar).Ended = true;
- return ret;
- }
-
- public IAsyncResult BeginExecuteReader ()
- {
- return BeginExecuteReader (null, null, CommandBehavior.Default);
- }
-
- public IAsyncResult BeginExecuteReader (CommandBehavior behavior)
- {
- return BeginExecuteReader (null, null, behavior);
- }
-
- public IAsyncResult BeginExecuteReader (AsyncCallback callback, object state)
- {
- return BeginExecuteReader (callback, state, CommandBehavior.Default);
- }
-
- public IAsyncResult BeginExecuteReader (AsyncCallback callback, object state, CommandBehavior behavior)
- {
- ValidateCommand ("BeginExecuteReader");
- this.behavior = behavior;
- SqlAsyncResult ar = new SqlAsyncResult (callback, state);
- ar.EndMethod = "EndExecuteReader";
- IAsyncResult tdsResult = BeginExecuteInternal (behavior, true,
- ar.BubbleCallback, state);
- ar.InternalResult = tdsResult;
- return ar;
- }
-
- public SqlDataReader EndExecuteReader (IAsyncResult ar)
- {
- ValidateAsyncResult (ar, "EndExecuteReader");
- EndExecuteInternal (ar);
- SqlDataReader reader = null;
- try {
- reader = new SqlDataReader (this);
+ GetOutputParameters ();
+ ((SqlAsyncResult) asyncResult).Ended = true;
+ return ret;
+ }
+
+ public IAsyncResult BeginExecuteReader ()
+ {
+ return BeginExecuteReader (null, null, CommandBehavior.Default);
+ }
+
+ public IAsyncResult BeginExecuteReader (CommandBehavior behavior)
+ {
+ return BeginExecuteReader (null, null, behavior);
+ }
+
+ public IAsyncResult BeginExecuteReader (AsyncCallback callback, object stateObject)
+ {
+ return BeginExecuteReader (callback, stateObject, CommandBehavior.Default);
+ }
+
+ public IAsyncResult BeginExecuteReader (AsyncCallback callback, object stateObject, CommandBehavior behavior)
+ {
+ ValidateCommand ("BeginExecuteReader", true);
+ this.behavior = behavior;
+ SqlAsyncResult ar = new SqlAsyncResult (callback, stateObject);
+ ar.EndMethod = "EndExecuteReader";
+ IAsyncResult tdsResult = BeginExecuteInternal (behavior, true,
+ ar.BubbleCallback, stateObject);
+ ar.InternalResult = tdsResult;
+ return ar;
+ }
+
+ public SqlDataReader EndExecuteReader (IAsyncResult asyncResult)
+ {
+ ValidateAsyncResult (asyncResult, "EndExecuteReader");
+ EndExecuteInternal (asyncResult);
+ SqlDataReader reader = null;
+ try {
+ reader = new SqlDataReader (this);
+ } catch (TdsTimeoutException e) {
+ throw SqlException.FromTdsInternalException ((TdsInternalException) e);
+ } catch (TdsInternalException e) {
+ // if behavior is closeconnection, even if it throws exception
+ // the connection has to be closed.
+ if ((behavior & CommandBehavior.CloseConnection) != 0)
+ Connection.Close ();
+ throw SqlException.FromTdsInternalException ((TdsInternalException) e);