NextResult() 공개 메소드

public NextResult ( ) : bool
리턴 bool
예제 #1
0
 public void MultipleResultSetsTest ()
 {
         DataTable dt1 = new DataTable ("test2");
         dt1.Columns.Add ("x", typeof (string));
         dt1.Rows.Add (new object [] {"test"} );
         dt1.Rows.Add (new object [] {"test1"} );
         dt1.AcceptChanges ();
         
         DataTable [] collection = new DataTable [] { dt, dt1 } ; 
         
         DataTableReader reader = new DataTableReader (collection);
         try {
                 int i = 0;
                 do {
                         while (reader.Read ())
                                 i++;
                 } while (reader.NextResult ());
                                 
                 Assert.AreEqual (5, i, "#1 rows should be of both the tables");
         } finally {
                 if (reader != null && !reader.IsClosed)
                         reader.Close ();
         }
 }
예제 #2
0
 public void NoRowsTest ()
 {
         dt.Rows.Clear ();
         dt.AcceptChanges ();
         
         DataTableReader reader = new DataTableReader (dt);
         try {
         
                 Assert.IsFalse (reader.Read (), "#1 there are no rows");
                 Assert.IsFalse (reader.NextResult (), "#2 there are no further resultsets");
         } finally {
                 if (reader != null && !reader.IsClosed)
                         reader.Close ();
         }
 }
예제 #3
0
                public void SchemaTest ()
                {
                        DataTable another = new DataTable ("another");
                        another.Columns.Add ("x", typeof (string));

                        another.Rows.Add (new object [] {"test 1" });
                        another.Rows.Add (new object [] {"test 2" });
                        another.Rows.Add (new object [] {"test 3" });

                        DataTableReader reader = new DataTableReader (new DataTable [] { dt, another });
                        try {
                                DataTable schema = reader.GetSchemaTable ();

                                Assert.AreEqual (dt.Columns.Count, schema.Rows.Count, "#1 should be same");
                                Assert.AreEqual (dt.Columns [1].DataType.ToString (), schema.Rows [1] ["DataType"].ToString (), "#2 data type should match");

                                reader.NextResult (); //schema should change here
                                schema = reader.GetSchemaTable ();

                                Assert.AreEqual (another.Columns.Count, schema.Rows.Count, "#3 should be same");
                                Assert.AreEqual (another.Columns [0].DataType.ToString (), schema.Rows [0] ["DataType"].ToString (), "#4 data type should match");
                        
                        } finally {
                                if (reader != null && !reader.IsClosed)
                                        reader.Close ();
                        }
                }