Example #1
0
		public void BeginExecuteXmlReaderExceptionTest ()
		{
			cmd = new SqlCommand ();
			try {
				SqlConnection conn = new SqlConnection (connectionString);
				conn.Open ();
				cmd.CommandText = "Select lname from employee where id<2 FOR XML AUTO, XMLDATA";
				cmd.Connection = conn;
				
				try {
					/*IAsyncResult result = */cmd.BeginExecuteXmlReader ();
				} catch (InvalidOperationException) {
					Assert.AreEqual (ConnectionManager.Singleton.ConnectionString, connectionString, "#1 Connection string has changed");
					return;
				}
				Assert.Fail ("Expected Exception InvalidOperationException not thrown");
			} finally {
				ConnectionManager.Singleton.CloseConnection ();
			}
		}
 private IAsyncResult DoBeginExecuteXmlReader(SqlCommand command, AsyncCallback callback, object state)
 {
     try
     {
         return WrappedAsyncOperation.BeginAsyncOperation(
             callback,
             cb => command.BeginExecuteXmlReader(cb, state),
             ar => new DaabAsyncResult(ar, command, false, false, DateTime.Now));
     }
     catch (Exception e)
     {
         instrumentationProvider.FireCommandFailedEvent(command.CommandText, ConnectionStringNoCredentials, e);
         throw;
     }
 }
Example #3
0
		public void BeginExecuteXmlReaderTest ()
		{
			cmd = new SqlCommand ();
			string connectionString1 = null;
			connectionString1 = ConnectionManager.Singleton.ConnectionString + "Asynchronous Processing=true";
			try {
				SqlConnection conn1 = new SqlConnection (connectionString1);
				conn1.Open ();
				cmd.CommandText = "Select lname from employee where id<2 FOR XML AUTO, XMLDATA";
				cmd.Connection = conn1;
			
				IAsyncResult result = cmd.BeginExecuteXmlReader ();
				XmlReader reader = cmd.EndExecuteXmlReader (result);
				while (reader.Read ()) {
					if (reader.LocalName.ToString () == "employee")
						Assert.AreEqual ("kumar", reader["lname"], "#1 ");
				}
			} finally {
				ConnectionManager.Singleton.CloseConnection ();
			}
		}