* SqlCommandBuilderTest.cs: Improve Get*Command tests.
authorGert Driesen <drieseng@users.sourceforge.net>
Sat, 3 Jan 2009 23:24:47 +0000 (23:24 -0000)
committerGert Driesen <drieseng@users.sourceforge.net>
Sat, 3 Jan 2009 23:24:47 +0000 (23:24 -0000)
* SqlCommandTest.cs: Fixed warning.
* SqlConnectionTest.cs: Removed unused property.
* SqlDataReaderTest.cs: Enabled GetChars test on 1.0
profile. Added GetValues test. Added and improved
GetSqlValue tests. Improved HasRows and NextResult
tests. Added GetFieldType tests. Added big batch of
schema-related tests.
* SqlParameterTest.cs: Moved disconnected tests to
System.Data test suite. Improved test for bug
#382635. Added test for failed conversion to SQL type.

svn path=/trunk/mcs/; revision=122382

mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandBuilderTest.cs
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandTest.cs
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlConnectionTest.cs
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlDataReaderTest.cs
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlParameterTest.cs

index 494fda5b54ececc57a7fd707ce7ca7f1dc9dff9f..5b4a66dc9b44379c5f1b9c0304f3f9682aa760be 100644 (file)
@@ -1,3 +1,17 @@
+2009-01-03  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * SqlCommandBuilderTest.cs: Improve Get*Command tests.
+       * SqlCommandTest.cs: Fixed warning.
+       * SqlConnectionTest.cs: Removed unused property.
+       * SqlDataReaderTest.cs: Enabled GetChars test on 1.0
+       profile. Added GetValues test. Added and improved
+       GetSqlValue tests. Improved HasRows and NextResult
+       tests. Added GetFieldType tests. Added big batch of
+       schema-related tests.
+       * SqlParameterTest.cs: Moved disconnected tests to
+       System.Data test suite. Improved test for bug
+       #382635. Added test for failed conversion to SQL type.
+
 2008-12-31  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * SqlCommandBuilderTest.cs: Improve Get*Command tests.
index 5244746e24d885bcb3c3ced3eb0fd38404d8e96b..d8a1ffa51d680f43a6edd583b1ffa9c2815d6997 100644 (file)
@@ -32,6 +32,9 @@ using System;
 using System.Data;
 using System.Data.Common;
 using System.Data.SqlClient;
+#if NET_2_0
+using System.Data.SqlTypes;
+#endif
 using Mono.Data;
 
 using NUnit.Framework;
@@ -43,218 +46,446 @@ namespace MonoTests.System.Data
        public class SqlCommandBuilderTest
        {
                [Test]
-               public void GetInsertCommandTest ()
+               public void GetInsertCommand1 ()
                {
-                       IDbConnection conn = ConnectionManager.Singleton.Connection;
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
+                       SqlCommand cmd = null;
+
                        try {
-                               ConnectionManager.Singleton.OpenConnection ();
-                               string selectQuery = "select id, fname from employee where id = 1";
-                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, (SqlConnection) conn);
+                               string selectQuery = "select id, fname, lname " +
+                                       "from employee where id = 1";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
                                DataSet ds = new DataSet ();
                                da.Fill (ds, "IntTest");
-                               Assert.AreEqual (1, ds.Tables.Count, "#1 atleast one table should be filled");
+                               Assert.AreEqual (1, ds.Tables.Count);
 
-                               SqlCommandBuilder cb = new SqlCommandBuilder (da);
-                               SqlCommand cmd = cb.GetInsertCommand ();
+                               SqlCommandBuilder cb;
+                               
+                               cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetInsertCommand ();
+#if NET_2_0
+                               Assert.AreEqual ("INSERT INTO [employee] ([id], " +
+                                       "[fname], [lname]) VALUES (@p1, @p2, @p3)",
+                                       cmd.CommandText, "#A1");
+#else
+                               Assert.AreEqual ("INSERT INTO employee( id , " +
+                                       "fname , lname ) VALUES ( @p1 , @p2 , @p3 )",
+                                       cmd.CommandText, "#A1");
+#endif
+                               Assert.AreSame (conn, cmd.Connection, "#A2");
+                               AssertInsertParameters (cmd, false, "#A3:");
+
+                               cb = new SqlCommandBuilder (da);
+                               cb.QuotePrefix = "\"";
+                               cmd = cb.GetInsertCommand ();
+
+#if NET_2_0
+                               Assert.AreEqual ("INSERT INTO \"employee] (\"id], " +
+                                       "\"fname], \"lname]) VALUES (@p1, @p2, @p3)",
+                                       cmd.CommandText, "#B1");
+#else
+                               Assert.AreEqual ("INSERT INTO \"employee( \"id , " +
+                                       "\"fname , \"lname ) VALUES ( @p1 , @p2 , @p3 )",
+                                       cmd.CommandText, "#B1");
+#endif
+                               Assert.AreSame (conn, cmd.Connection, "#B2");
+                               AssertInsertParameters (cmd, false, "#B3:");
+
+                               cb = new SqlCommandBuilder (da);
+#if NET_2_0
+                               cb.QuoteSuffix = "\"";
+#else
+                               cb.QuoteSuffix = "´";
+#endif
+                               cmd = cb.GetInsertCommand ();
+#if NET_2_0
+                               Assert.AreEqual ("INSERT INTO [employee\" ([id\", "
+                                       + "[fname\", [lname\") VALUES (@p1, @p2, @p3)",
+                                       cmd.CommandText, "#C1");
+#else
+                               Assert.AreEqual ("INSERT INTO employee´( id´ , " +
+                                       "fname´ , lname´ ) VALUES ( @p1 , @p2 , @p3 )",
+                                       cmd.CommandText, "#C1");
+#endif
+                               Assert.AreSame (conn, cmd.Connection, "#C2");
+                               AssertInsertParameters (cmd, false, "#C3");
+
+                               cb = new SqlCommandBuilder (da);
+                               cb.QuotePrefix = "\"";
+#if NET_2_0
+                               cb.QuoteSuffix = "\"";
+#else
+                               cb.QuoteSuffix = "´";
+#endif
+                               cmd = cb.GetInsertCommand ();
 #if NET_2_0
-                               Assert.AreEqual ("INSERT INTO [employee] ([id], [fname]) VALUES (@p1, @p2)",
-                                               cmd.CommandText, "#2");
+                               Assert.AreEqual ("INSERT INTO \"employee\" (\"id\", " +
+                                       "\"fname\", \"lname\") VALUES (@p1, @p2, @p3)",
+                                       cmd.CommandText, "#D1");
 #else
-                               Assert.AreEqual ("INSERT INTO employee (id, fname) VALUES (@p1, @p2)",
-                                               cmd.CommandText, "#2");
+                               Assert.AreEqual ("INSERT INTO \"employee´( \"id´ , " +
+                                       "\"fname´ , \"lname´ ) VALUES ( @p1 , @p2 , @p3 )",
+                                       cmd.CommandText, "#D1");
 #endif
+                               Assert.AreSame (conn, cmd.Connection, "#D2");
+                               AssertInsertParameters (cmd, false, "#D3:");
                        } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
                                ConnectionManager.Singleton.CloseConnection ();
                        }
                }
 
                [Test]
-               public void GetInsertCommandTestWithExpression ()
+               public void GetInsertCommand1_Expression ()
                {
-                       IDbConnection conn = ConnectionManager.Singleton.Connection;
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
+                       SqlCommand cmd = null;
+
                        try {
-                               ConnectionManager.Singleton.OpenConnection ();
-                               string selectQuery = "select id, fname, id+1 as next_id from employee where id = 1";
-                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, (SqlConnection) conn);
+                               string selectQuery = "select id, fname, lname, " +
+                                       "id+1 as next_id from employee where " +
+                                       "id = 1";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
                                DataSet ds = new DataSet ();
                                da.Fill (ds, "IntTest");
-                               Assert.AreEqual (1, ds.Tables.Count, "#1 atleast one table should be filled");
+                               Assert.AreEqual (1, ds.Tables.Count);
 
                                SqlCommandBuilder cb = new SqlCommandBuilder (da);
-                               SqlCommand cmd = cb.GetInsertCommand ();
+                               cmd = cb.GetInsertCommand ();
 #if NET_2_0
-                               Assert.AreEqual ("INSERT INTO [employee] ([id], [fname]) VALUES (@p1, @p2)",
-                                               cmd.CommandText, "#2");
+                               Assert.AreEqual ("INSERT INTO [employee] " +
+                                       "([id], [fname], [lname]) VALUES " +
+                                       "(@p1, @p2, @p3)", cmd.CommandText, "#1");
 #else
-                               Assert.AreEqual ("INSERT INTO employee (id, fname) VALUES (@p1, @p2)",
-                                               cmd.CommandText, "#2");
+                               Assert.AreEqual ("INSERT INTO employee( id , " +
+                                       "fname , lname ) VALUES ( @p1 , @p2 , " +
+                                       "@p3 )", cmd.CommandText, "#1");
 #endif
+                               Assert.AreSame (conn, cmd.Connection, "#2");
+                               AssertInsertParameters (cmd, false, "#3:");
                        } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
                                ConnectionManager.Singleton.CloseConnection ();
                        }
                }
 
-               [Test]
-               public void GetUpdateCommandTest ()
+#if NET_2_0
+               [Test] // GetInsertCommand (Boolean)
+               public void GetInsertCommand2 ()
                {
-                       IDbConnection conn = ConnectionManager.Singleton.Connection;
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
+                       SqlCommand cmd = null;
+
                        try {
-                               string selectQuery = "select id, fname, lname, id+1 as next_id from employee where id = 1";
-                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, (SqlConnection) conn);
+                               string selectQuery = "select id, fname, lname " +
+                                       "from employee where id = 1";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
                                DataSet ds = new DataSet ();
                                da.Fill (ds, "IntTest");
-                               Assert.AreEqual (1, ds.Tables.Count, "#1 atleast one table should be filled");
+                               Assert.AreEqual (1, ds.Tables.Count);
 
-                               SqlCommandBuilder cb = new SqlCommandBuilder (da);
-                               SqlCommand cmd = cb.GetUpdateCommand ();
-#if NET_2_0
-                               Assert.AreEqual ("UPDATE [employee] SET [id] = @p1, [fname] = @p2, [lname] = @p3 WHERE (([id] = @p4)" +
-                                               " AND ([fname] = @p5) AND ((@p6 = 1 AND [lname] IS NULL) OR ([lname] = @p7)))",
-                                               cmd.CommandText, "#2");
-#else
-                               Assert.AreEqual ("UPDATE employee SET id = @p1, fname = @p2, lname = @p3 WHERE ((id = @p4)" +
-                                               " AND (fname = @p5) AND ((@p6 = 1 AND lname IS NULL) OR (lname = @p7)))",
-                                               cmd.CommandText, "#2");
-#endif
-                               Assert.AreEqual (7, cmd.Parameters.Count, "#3");
+                               SqlCommandBuilder cb;
+
+                               cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetInsertCommand (true);
+                               Assert.AreEqual ("INSERT INTO [employee] ([id], " +
+                                       "[fname], [lname]) VALUES (@id, @fname, " +
+                                       "@lname)", cmd.CommandText, "#A1");
+                               Assert.AreSame (conn, cmd.Connection, "#A2");
+                               AssertInsertParameters (cmd, true, "#A3:");
+
+                               cmd = cb.GetInsertCommand (false);
+                               Assert.AreEqual ("INSERT INTO [employee] ([id], " +
+                                       "[fname], [lname]) VALUES (@id, @fname, " +
+                                       "@lname)", cmd.CommandText, "#B1");
+                               Assert.AreSame (conn, cmd.Connection, "#B2");
+                               AssertInsertParameters (cmd, true, "#B3:");
+
+                               cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetInsertCommand (false);
+                               Assert.AreEqual ("INSERT INTO [employee] ([id], " +
+                                       "[fname], [lname]) VALUES (@p1, @p2, @p3)",
+                                       cmd.CommandText, "#C1");
+                               Assert.AreSame (conn, cmd.Connection, "#C2");
+                               AssertInsertParameters (cmd, false, "#C3:");
+
+                               cmd = cb.GetInsertCommand (true);
+                               Assert.AreEqual ("INSERT INTO [employee] ([id], " +
+                                       "[fname], [lname]) VALUES (@id, @fname, " +
+                                       "@lname)", cmd.CommandText, "#D1");
+                               Assert.AreSame (conn, cmd.Connection, "#D2");
+                               AssertInsertParameters (cmd, true, "#D3:");
                        } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
                                ConnectionManager.Singleton.CloseConnection ();
                        }
                }
+#endif
 
-#if NET_2_0
-               [Test]
-               public void GetUpdateCommandBoolTest ()
+               [Test] // GetUpdateCommand ()
+               public void GetUpdateCommand1 ()
                {
-                       IDbConnection conn = ConnectionManager.Singleton.Connection;
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+
+                       SqlCommand cmd = null;
+
                        try {
-                               string selectQuery = "select id, fname, lname, id+1 as next_id from employee where id = 1";
-                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, (SqlConnection) conn);
+                               string selectQuery = "select id, fname, lname, " +
+                                       "id+1 as next_id from employee where " +
+                                       "id = 3 and lname = 'A' and fname = 'B'";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
                                DataSet ds = new DataSet ();
                                da.Fill (ds, "IntTest");
-                               Assert.AreEqual (1, ds.Tables.Count, "#1 atleast one table should be filled");
+                               Assert.AreEqual (1, ds.Tables.Count);
 
                                SqlCommandBuilder cb = new SqlCommandBuilder (da);
-                               SqlCommand cmd = cb.GetUpdateCommand (true);
-                               Assert.AreEqual ("UPDATE [employee] SET [id] = @id, [fname] = @fname, [lname] = @lname WHERE (([id] = @id)" +
-                                               " AND ([fname] = @fname) AND ((@lname = 1 AND [lname] IS NULL) OR ([lname] = @lname)))",
-                                               cmd.CommandText, "#2");
-                               Assert.AreEqual (7, cmd.Parameters.Count, "#3");
+                               cmd = cb.GetUpdateCommand ();
+#if NET_2_0
+                               Assert.AreEqual ("UPDATE [employee] SET [id] = @p1, " +
+                                       "[fname] = @p2, [lname] = @p3 WHERE (([id] = @p4) " +
+                                       "AND ([fname] = @p5) AND ((@p6 = 1 " +
+                                       "AND [lname] IS NULL) OR ([lname] = @p7)))",
+                                       cmd.CommandText, "#1");
+#else
+                               Assert.AreEqual ("UPDATE employee SET id = @p1 , " +
+                                       "fname = @p2 , lname = @p3 WHERE ( (id = @p4) " +
+                                       "AND ((@p5 = 1 AND fname IS NULL) OR " +
+                                       "(fname = @p6)) AND ((@p7 = 1 AND " +
+                                       "lname IS NULL) OR (lname = @p8)) )",
+                                       cmd.CommandText, "#1");
+#endif
+                               Assert.AreSame (conn, cmd.Connection, "#2");
+                               AssertUpdateParameters (cmd, false, "#3:");
                        } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
                                ConnectionManager.Singleton.CloseConnection ();
                        }
                }
-#endif
-               [Test]
-               public void GetUpdateCommandTest_CheckNonUpdatableColumns ()
+
+               [Test] // GetUpdateCommand ()
+               public void GetUpdateCommand1_AutoIncrement ()
                {
-                       IDbConnection conn = ConnectionManager.Singleton.Connection;
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
+                       SqlCommand cmd = null;
+
                        try {
-                               ConnectionManager.Singleton.OpenConnection ();
-                               IDbCommand cmd = conn.CreateCommand ();
+                               cmd = conn.CreateCommand ();
                                cmd.CommandText = "create table #tmp_table (id int primary key , counter int identity(1,1), value varchar(10))";
                                cmd.ExecuteNonQuery ();
 
                                string selectQuery = "select id, counter, value, id+1 as next_id from #tmp_table";
-                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, (SqlConnection) conn);
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
                                DataSet ds = new DataSet ();
                                da.Fill (ds);
-                               Assert.AreEqual (1, ds.Tables.Count, "#1"); 
-                               Assert.AreEqual (4, ds.Tables [0].Columns.Count, "#2");
+                               Assert.AreEqual (1, ds.Tables.Count);
+                               Assert.AreEqual (4, ds.Tables [0].Columns.Count);
 
                                SqlCommandBuilder cb = new SqlCommandBuilder (da);
-                               SqlCommand updateCmd = cb.GetUpdateCommand ();
-#if NET_2_0
-                               Assert.AreEqual ("UPDATE [#tmp_table] SET [id] = @p1, [value] = @p2 WHERE (([id] = @p3) AND (" +
-                                                       "[counter] = @p4) AND ((@p5 = 1 AND [value] IS NULL) OR ([value] = @p6)))",
-                                               updateCmd.CommandText, "#3");
-#else
-                               Assert.AreEqual ("UPDATE #tmp_table SET id = @p1, value = @p2 WHERE ((id = @p3) AND (" +
-                                                       "counter = @p4) AND ((@p5 = 1 AND value IS NULL) OR (value = @p6)))",
-                                               updateCmd.CommandText, "#3");
-#endif
-                               Assert.AreEqual (6, updateCmd.Parameters.Count, "#4");
-
-                               SqlCommand delCmd = cb.GetDeleteCommand ();
+                               cmd = cb.GetUpdateCommand ();
 #if NET_2_0
-                               Assert.AreEqual ("DELETE FROM [#tmp_table] WHERE (([id] = @p1) AND ([counter] = @p2) AND " +
-                                               "((@p3 = 1 AND [value] IS NULL) OR ([value] = @p4)))", delCmd.CommandText, "#5");
+                               Assert.AreEqual ("UPDATE [#tmp_table] SET [id] = @p1, " +
+                                       "[value] = @p2 WHERE (([id] = @p3) AND (" +
+                                       "[counter] = @p4) AND ((@p5 = 1 AND [value] IS NULL) " +
+                                       "OR ([value] = @p6)))", cmd.CommandText, "#1");
+                               Assert.AreEqual (6, cmd.Parameters.Count, "#2");
 #else
-                               Assert.AreEqual ("DELETE FROM #tmp_table WHERE ((id = @p1) AND (counter = @p2) AND " +
-                                               "((@p3 = 1 AND value IS NULL) OR (value = @p4)))", delCmd.CommandText, "#5");
+                               Assert.AreEqual ("UPDATE #tmp_table SET id = @p1 , " +
+                                       "value = @p2 WHERE ( (id = @p3) AND (" +
+                                       "(@p4 = 1 AND counter IS NULL) OR (counter = @p5)) " +
+                                       "AND ((@p6 = 1 AND value IS NULL) OR (value = @p7)) )",
+                                       cmd.CommandText, "#1");
+                               Assert.AreEqual (7, cmd.Parameters.Count, "#2");
 #endif
-                               Assert.AreEqual (4, delCmd.Parameters.Count, "#6");
                        } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
                                ConnectionManager.Singleton.CloseConnection ();
                        }
                }
 
-               [Test]
-               public void GetUpdateDeleteCommand_CheckParameters ()
+               [Test] // GetUpdateCommand ()
+               public void GetUpdateCommand1_CheckParameters ()
                {
-                       IDbConnection conn = ConnectionManager.Singleton.Connection;
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
+                       SqlCommand cmd = null;
+
                        try {
-                               ConnectionManager.Singleton.OpenConnection ();
-                               SqlDataAdapter adapter = new SqlDataAdapter ("select id, type_varchar from string_family",
-                                                               (SqlConnection)conn);
+                               SqlDataAdapter adapter = new SqlDataAdapter (
+                                       "select id, type_varchar from string_family",
+                                       conn);
                                SqlCommandBuilder cb = new SqlCommandBuilder (adapter);
 
-                               SqlCommand updateCommand = cb.GetUpdateCommand ();
-                               Assert.AreEqual (5, updateCommand.Parameters.Count, "#1");
-                               Assert.AreEqual (SqlDbType.Int, updateCommand.Parameters ["@p4"].SqlDbType, "#2");
-                               Assert.AreEqual (1, updateCommand.Parameters ["@p4"].Value, "#3");
+                               cmd = cb.GetUpdateCommand ();
+                               Assert.AreEqual (5, cmd.Parameters.Count, "#1");
+                               Assert.AreEqual (SqlDbType.Int, cmd.Parameters ["@p4"].SqlDbType, "#2");
+                               Assert.AreEqual (1, cmd.Parameters ["@p4"].Value, "#3");
 
-                               SqlCommand delCommand = cb.GetDeleteCommand ();
-                               Assert.AreEqual (3, delCommand.Parameters.Count, "#4");
-                               Assert.AreEqual (SqlDbType.Int, delCommand.Parameters ["@p2"].SqlDbType, "#5");
-                               Assert.AreEqual (1, delCommand.Parameters ["@p2"].Value, "#6");
+                               cmd = cb.GetDeleteCommand ();
+                               Assert.AreEqual (3, cmd.Parameters.Count, "#4");
+                               Assert.AreEqual (SqlDbType.Int, cmd.Parameters ["@p2"].SqlDbType, "#5");
+                               Assert.AreEqual (1, cmd.Parameters ["@p2"].Value, "#6");
                        } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
                                ConnectionManager.Singleton.CloseConnection ();
                        }
                }
-               
+
 #if NET_2_0
-               [Test]
-               public void GetUpdateCommandBoolTest_CheckNonUpdatableColumns ()
+               [Test] // GetUpdateCommand (Boolean)
+               public void GetUpdateCommand2 ()
                {
-                       IDbConnection conn = ConnectionManager.Singleton.Connection;
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+
+                       SqlCommand cmd = null;
+
                        try {
-                               ConnectionManager.Singleton.OpenConnection ();
-                               IDbCommand cmd = conn.CreateCommand ();
+                               string selectQuery = "select id, fname, lname, id+1 as next_id from employee where id = 1";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
+                               DataSet ds = new DataSet ();
+                               da.Fill (ds, "IntTest");
+                               Assert.AreEqual (1, ds.Tables.Count);
+
+                               SqlCommandBuilder cb;
+               
+                               cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetUpdateCommand (true);
+                               Assert.AreEqual ("UPDATE [employee] SET [id] = @id, " +
+                                       "[fname] = @fname, [lname] = @lname WHERE " +
+                                       "(([id] = @Original_id) AND ([fname] = " +
+                                       "@Original_fname) AND ((@IsNull_lname = 1 " +
+                                       "AND [lname] IS NULL) OR ([lname] = " +
+                                       "@Original_lname)))", cmd.CommandText, "#A1");
+                               Assert.AreSame (conn, cmd.Connection, "#A2");
+                               AssertUpdateParameters (cmd, true, "#A3:");
+
+                               cmd = cb.GetUpdateCommand (false);
+                               Assert.AreEqual ("UPDATE [employee] SET [id] = @id, " +
+                                       "[fname] = @fname, [lname] = @lname WHERE " +
+                                       "(([id] = @Original_id) AND ([fname] = " +
+                                       "@Original_fname) AND ((@IsNull_lname = 1 " +
+                                       "AND [lname] IS NULL) OR ([lname] = " +
+                                       "@Original_lname)))", cmd.CommandText, "#B1");
+                               Assert.AreSame (conn, cmd.Connection, "#B2");
+                               AssertUpdateParameters (cmd, true, "#B3:");
+
+                               cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetUpdateCommand (false);
+                               Assert.AreEqual ("UPDATE [employee] SET [id] = @p1, " +
+                                       "[fname] = @p2, [lname] = @p3 WHERE " +
+                                       "(([id] = @p4) AND ([fname] = @p5) AND " +
+                                       "((@p6 = 1 AND [lname] IS NULL) OR " +
+                                       "([lname] = @p7)))", cmd.CommandText, "#C1");
+                               Assert.AreSame (conn, cmd.Connection, "#C2");
+                               AssertUpdateParameters (cmd, false, "#C3:");
+
+                               cmd = cb.GetUpdateCommand (true);
+                               Assert.AreEqual ("UPDATE [employee] SET [id] = @id, " +
+                                       "[fname] = @fname, [lname] = @lname WHERE " +
+                                       "(([id] = @Original_id) AND ([fname] = " +
+                                       "@Original_fname) AND ((@IsNull_lname = 1 " +
+                                       "AND [lname] IS NULL) OR ([lname] = " +
+                                       "@Original_lname)))", cmd.CommandText, "#D1");
+                               Assert.AreSame (conn, cmd.Connection, "#D2");
+                               AssertUpdateParameters (cmd, true, "#D3:");
+                       } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
+                               ConnectionManager.Singleton.CloseConnection ();
+                       }
+               }
+
+               [Test] // GetUpdateCommand (Boolean)
+               public void GetUpdateCommand2_AutoIncrement ()
+               {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
+                       SqlCommand cmd = null;
+
+                       try {
+                               cmd = conn.CreateCommand ();
                                cmd.CommandText = "create table #tmp_table (id int primary key , counter int identity(1,1), value varchar(10))";
                                cmd.ExecuteNonQuery ();
 
                                string selectQuery = "select id, counter, value, id+1 as next_id from #tmp_table";
-                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, (SqlConnection) conn);
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
                                DataSet ds = new DataSet ();
                                da.Fill (ds);
-                               Assert.AreEqual (1, ds.Tables.Count, "#1"); 
-                               Assert.AreEqual (4, ds.Tables [0].Columns.Count, "#2");
+                               Assert.AreEqual (1, ds.Tables.Count);
+                               Assert.AreEqual (4, ds.Tables [0].Columns.Count);
 
-                               SqlCommandBuilder cb = new SqlCommandBuilder (da);
-                               SqlCommand updateCmd = cb.GetUpdateCommand (true);
-                               Assert.AreEqual ("UPDATE [#tmp_table] SET [id] = @id, [value] = @value WHERE (([id] = @id) AND (" +
-                                                       "[counter] = @counter) AND ((@value = 1 AND [value] IS NULL) OR ([value] = @value)))",
-                                               updateCmd.CommandText, "#3");
-                               Assert.AreEqual (6, updateCmd.Parameters.Count, "#4");
-
-                               SqlCommand delCmd = cb.GetDeleteCommand (true);
-                               Assert.AreEqual ("DELETE FROM [#tmp_table] WHERE (([id] = @id) AND ([counter] = @counter) AND " +
-                                               "((@value = 1 AND [value] IS NULL) OR ([value] = @value)))", delCmd.CommandText, "#5");
-                               Assert.AreEqual (4, delCmd.Parameters.Count, "#6");
+                               SqlCommandBuilder cb;
+               
+                               cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetUpdateCommand (true);
+                               Assert.AreEqual ("UPDATE [#tmp_table] SET [id] = @id, " +
+                                       "[value] = @value WHERE (([id] = @Original_id) " +
+                                       "AND ([counter] = @Original_counter) AND " +
+                                       "((@IsNull_value = 1 AND [value] IS NULL) " +
+                                       "OR ([value] = @Original_value)))",
+                                       cmd.CommandText, "#A1");
+                               Assert.AreEqual (6, cmd.Parameters.Count, "#A2");
+
+                               cmd = cb.GetUpdateCommand (false);
+                               Assert.AreEqual ("UPDATE [#tmp_table] SET [id] = @id, " +
+                                       "[value] = @value WHERE (([id] = @Original_id) " +
+                                       "AND ([counter] = @Original_counter) AND " +
+                                       "((@IsNull_value = 1 AND [value] IS NULL) " +
+                                       "OR ([value] = @Original_value)))",
+                                       cmd.CommandText, "#B1");
+                               Assert.AreEqual (6, cmd.Parameters.Count, "#B2");
+
+                               cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetUpdateCommand (false);
+                               Assert.AreEqual ("UPDATE [#tmp_table] SET [id] = @p1, " +
+                                       "[value] = @p2 WHERE (([id] = @p3) " +
+                                       "AND ([counter] = @p4) AND ((@p5 = 1 " +
+                                       "AND [value] IS NULL) OR ([value] = @p6)))",
+                                       cmd.CommandText, "#C1");
+                               Assert.AreEqual (6, cmd.Parameters.Count, "#C2");
+
+                               cmd = cb.GetUpdateCommand (true);
+                               Assert.AreEqual ("UPDATE [#tmp_table] SET [id] = @id, " +
+                                       "[value] = @value WHERE (([id] = @Original_id) " +
+                                       "AND ([counter] = @Original_counter) AND " +
+                                       "((@IsNull_value = 1 AND [value] IS NULL) " +
+                                       "OR ([value] = @Original_value)))",
+                                       cmd.CommandText, "#D1");
+                               Assert.AreEqual (6, cmd.Parameters.Count, "#D2");
                        } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
                                ConnectionManager.Singleton.CloseConnection ();
                        }
                }
 
-               [Test]
-               public void GetUpdateDeleteCommandBoolTest_CheckParameters ()
+               [Test] // GetUpdateCommand (Boolean)
+               public void GetUpdateDeleteCommand2_CheckParameters ()
                {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
+                       SqlCommand cmd = null;
+
                        try {
-                               ConnectionManager.Singleton.OpenConnection ();
-                               IDbConnection conn = ConnectionManager.Singleton.Connection;
-                               SqlDataAdapter adapter = new SqlDataAdapter ("select id, type_varchar from string_family",
-                                                               (SqlConnection)conn);
+                               SqlDataAdapter adapter = new SqlDataAdapter (
+                                       "select id, type_varchar from string_family",
+                                       conn);
                                SqlCommandBuilder cb = new SqlCommandBuilder (adapter);
 
                                SqlCommand updateCommand = cb.GetUpdateCommand (true);
@@ -283,6 +514,8 @@ namespace MonoTests.System.Data
                                Assert.AreEqual (SqlDbType.VarChar, delCommand.Parameters [2].SqlDbType, "#B: SqlDbType (2)");
                                Assert.IsNull (delCommand.Parameters [2].Value, "#B: Value (2)");
                        } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
                                ConnectionManager.Singleton.CloseConnection ();
                        }
                }
@@ -291,11 +524,12 @@ namespace MonoTests.System.Data
                [Test]
                public void GetUpdateCommandDBConcurrencyExceptionTest ()
                {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
                        try {
-                               ConnectionManager.Singleton.OpenConnection ();
-                               IDbConnection conn = ConnectionManager.Singleton.Connection;
                                string selectQuery = "select id, fname from employee where id = 1";
-                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, (SqlConnection) conn);
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
                                DataSet ds = new DataSet ();
                                da.Fill (ds, "IntTest");
                                Assert.AreEqual (1, ds.Tables.Count);
@@ -329,11 +563,12 @@ namespace MonoTests.System.Data
                [Test]
                public void GetDeleteCommandDBConcurrencyExceptionTest ()
                {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
                        try {
-                               ConnectionManager.Singleton.OpenConnection ();
-                               IDbConnection conn = ConnectionManager.Singleton.Connection;
                                string selectQuery = "select id, fname from employee where id = 1";
-                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, (SqlConnection) conn);
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
                                DataSet ds = new DataSet ();
                                da.Fill (ds, "IntTest");
                                Assert.AreEqual (1, ds.Tables.Count);
@@ -364,34 +599,241 @@ namespace MonoTests.System.Data
                        }
                }
 
-               [Test]
-               public void GetDeleteCommandTest ()
+               [Test] // GetDeleteCommand ()
+               public void GetDeleteCommand1 ()
                {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
+                       SqlCommand cmd = null;
+
                        try {
-                               ConnectionManager.Singleton.OpenConnection ();
-                               IDbConnection conn = ConnectionManager.Singleton.Connection;
-                               string selectQuery = "select id, fname, lname, id+1 as next_id from employee where id = 1";
-                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, (SqlConnection) conn);
+                               string selectQuery = "select id, fname, lname, " +
+                                       "id+2 as next_id from employee where " +
+                                       "id = 3 and lname = 'A' and fname = 'B'";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
                                DataSet ds = new DataSet ();
                                da.Fill (ds, "IntTest");
-                               Assert.AreEqual (1, ds.Tables.Count, "#1 atleast one table should be filled");
+                               Assert.AreEqual (1, ds.Tables.Count);
+
+                               SqlCommandBuilder cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetDeleteCommand ();
+#if NET_2_0
+                               Assert.AreEqual ("DELETE FROM [employee] WHERE " +
+                                       "(([id] = @p1) AND ([fname] = @p2) AND " +
+                                       "((@p3 = 1 AND [lname] IS NULL) OR " +
+                                       "([lname] = @p4)))", cmd.CommandText, "#1");
+#else
+                               Assert.AreEqual ("DELETE FROM  employee WHERE ( " +
+                                       "(id = @p1) AND ((@p2 = 1 AND fname IS NULL) " +
+                                       "OR (fname = @p3)) AND ((@p4 = 1 AND " +
+                                       "lname IS NULL) OR (lname = @p5)) )",
+                                       cmd.CommandText, "#1");
+#endif
+                               Assert.AreSame (conn, cmd.Connection, "#2");
+                               AssertDeleteParameters (cmd, false, "#3:");
+                       } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
+                               ConnectionManager.Singleton.CloseConnection ();
+                       }
+               }
+
+               [Test] // GetDeleteCommand ()
+               public void GetDeleteCommand1_AutoIncrement ()
+               {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
+                       SqlCommand cmd = null;
+
+                       try {
+                               cmd = conn.CreateCommand ();
+                               cmd.CommandText = "create table #tmp_table (id int primary key , counter int identity(1,1), value varchar(10))";
+                               cmd.ExecuteNonQuery ();
+
+                               string selectQuery = "select id, counter, value, id+1 as next_id from #tmp_table";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
+                               DataSet ds = new DataSet ();
+                               da.Fill (ds);
+                               Assert.AreEqual (1, ds.Tables.Count);
+                               Assert.AreEqual (4, ds.Tables [0].Columns.Count);
 
                                SqlCommandBuilder cb = new SqlCommandBuilder (da);
-                               SqlCommand cmd = cb.GetDeleteCommand ();
+                               cmd = cb.GetDeleteCommand ();
 #if NET_2_0
-                               Assert.AreEqual ("DELETE FROM [employee] WHERE (([id] = @p1) AND ([fname] = @p2) AND " +
-                                                "((@p3 = 1 AND [lname] IS NULL) OR ([lname] = @p4)))", cmd.CommandText, "#2");
+                               Assert.AreEqual ("DELETE FROM [#tmp_table] WHERE " +
+                                       "(([id] = @p1) AND ([counter] = @p2) AND " +
+                                       "((@p3 = 1 AND [value] IS NULL) OR ([value] = @p4)))",
+                                       cmd.CommandText, "#1");
+                               Assert.AreEqual (4, cmd.Parameters.Count, "#2");
 #else
-                               Assert.AreEqual ("DELETE FROM employee WHERE ((id = @p1) AND (fname = @p2) AND " +
-                                                "((@p3 = 1 AND lname IS NULL) OR (lname = @p4)))", cmd.CommandText, "#2");
+                               Assert.AreEqual ("DELETE FROM  #tmp_table WHERE ( " +
+                                       "(id = @p1) AND ((@p2 = 1 AND counter IS NULL) " +
+                                       "OR (counter = @p3)) AND ((@p4 = 1 AND value " +
+                                       "IS NULL) OR (value = @p5)) )",
+                                       cmd.CommandText, "#1");
+                               Assert.AreEqual (5, cmd.Parameters.Count, "#2");
 #endif
                        } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
+                               ConnectionManager.Singleton.CloseConnection ();
+                       }
+               }
+
+               [Test] // GetDeleteCommand ()
+               public void GetDeleteCommand1_CheckParameters ()
+               {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
+                       SqlCommand cmd = null;
+
+                       try {
+                               SqlDataAdapter adapter = new SqlDataAdapter (
+                                       "select id, type_varchar from string_family",
+                                       conn);
+                               SqlCommandBuilder cb = new SqlCommandBuilder (adapter);
+
+                               cmd = cb.GetDeleteCommand ();
+                               Assert.AreEqual (3, cmd.Parameters.Count, "#1");
+                               Assert.AreEqual (SqlDbType.Int, cmd.Parameters ["@p2"].SqlDbType, "#2");
+                               Assert.AreEqual (1, cmd.Parameters ["@p2"].Value, "#3");
+                       } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
+                               ConnectionManager.Singleton.CloseConnection ();
+                       }
+               }
+
+#if NET_2_0
+               [Test] // GetDeleteCommand ()
+               public void GetDeleteCommand2 ()
+               {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
+                       SqlCommand cmd = null;
+
+                       try {
+                               string selectQuery = "select id, fname, lname, id+2 as next_id from employee where id = 3";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
+                               DataSet ds = new DataSet ();
+                               da.Fill (ds, "IntTest");
+                               Assert.AreEqual (1, ds.Tables.Count);
+
+                               SqlCommandBuilder cb;
+               
+                               cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetDeleteCommand (true);
+                               Assert.AreEqual ("DELETE FROM [employee] WHERE " +
+                                       "(([id] = @Original_id) AND ([fname] = " +
+                                       "@Original_fname) AND ((@IsNull_lname = 1 " +
+                                       "AND [lname] IS NULL) OR ([lname] = " +
+                                       "@Original_lname)))", cmd.CommandText, "#A1");
+                               Assert.AreSame (conn, cmd.Connection, "#A2");
+                               AssertDeleteParameters (cmd, true, "#A3:");
+
+                               cmd = cb.GetDeleteCommand (false);
+                               Assert.AreEqual ("DELETE FROM [employee] WHERE " +
+                                       "(([id] = @Original_id) AND ([fname] = " +
+                                       "@Original_fname) AND ((@IsNull_lname = 1 " +
+                                       "AND [lname] IS NULL) OR ([lname] = " +
+                                       "@Original_lname)))", cmd.CommandText, "#B1");
+                               Assert.AreSame (conn, cmd.Connection, "#B2");
+                               AssertDeleteParameters (cmd, true, "#B3:");
+
+                               cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetDeleteCommand (false);
+                               Assert.AreEqual ("DELETE FROM [employee] WHERE " +
+                                       "(([id] = @p1) AND ([fname] = @p2) AND " +
+                                       "((@p3 = 1 AND [lname] IS NULL) OR " +
+                                       "([lname] = @p4)))", cmd.CommandText, "#C1");
+                               Assert.AreSame (conn, cmd.Connection, "#C2");
+                               AssertDeleteParameters (cmd, false, "#C3:");
+
+                               cmd = cb.GetDeleteCommand (true);
+                               Assert.AreEqual ("DELETE FROM [employee] WHERE " +
+                                       "(([id] = @Original_id) AND ([fname] = " +
+                                       "@Original_fname) AND ((@IsNull_lname = 1 " +
+                                       "AND [lname] IS NULL) OR ([lname] = " +
+                                       "@Original_lname)))", cmd.CommandText, "#D1");
+                               Assert.AreSame (conn, cmd.Connection, "#D2");
+                               AssertDeleteParameters (cmd, true, "#D3:");
+
+                       } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
+                               ConnectionManager.Singleton.CloseConnection ();
+                       }
+               }
+
+               [Test] // GetDeleteCommand (Boolean)
+               public void GetDeleteCommand2_AutoIncrement ()
+               {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
+                       SqlCommand cmd = null;
+
+                       try {
+                               cmd = conn.CreateCommand ();
+                               cmd.CommandText = "create table #tmp_table (id int primary key , counter int identity(1,1), value varchar(10))";
+                               cmd.ExecuteNonQuery ();
+
+                               string selectQuery = "select id, counter, value, id+1 as next_id from #tmp_table";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
+                               DataSet ds = new DataSet ();
+                               da.Fill (ds);
+                               Assert.AreEqual (1, ds.Tables.Count);
+                               Assert.AreEqual (4, ds.Tables [0].Columns.Count);
+
+                               SqlCommandBuilder cb;
+               
+                               cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetDeleteCommand (true);
+                               Assert.AreEqual ("DELETE FROM [#tmp_table] WHERE " +
+                                       "(([id] = @Original_id) AND ([counter] = @Original_counter) " +
+                                       "AND ((@IsNull_value = 1 AND [value] IS NULL) " +
+                                       "OR ([value] = @Original_value)))",
+                                       cmd.CommandText, "#A1");
+                               Assert.AreEqual (4, cmd.Parameters.Count, "#A2");
+
+                               cmd = cb.GetDeleteCommand (false);
+                               Assert.AreEqual ("DELETE FROM [#tmp_table] WHERE " +
+                                       "(([id] = @Original_id) AND ([counter] = @Original_counter) " +
+                                       "AND ((@IsNull_value = 1 AND [value] IS NULL) " +
+                                       "OR ([value] = @Original_value)))",
+                                       cmd.CommandText, "#B1");
+                               Assert.AreEqual (4, cmd.Parameters.Count, "#B2");
+
+                               cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetDeleteCommand (false);
+                               Assert.AreEqual ("DELETE FROM [#tmp_table] WHERE " +
+                                       "(([id] = @p1) AND ([counter] = @p2) " +
+                                       "AND ((@p3 = 1 AND [value] IS NULL) " +
+                                       "OR ([value] = @p4)))",
+                                       cmd.CommandText, "#C1");
+                               Assert.AreEqual (4, cmd.Parameters.Count, "#C2");
+
+                               cmd = cb.GetDeleteCommand (true);
+                               Assert.AreEqual ("DELETE FROM [#tmp_table] WHERE " +
+                                       "(([id] = @Original_id) AND ([counter] = @Original_counter) " +
+                                       "AND ((@IsNull_value = 1 AND [value] IS NULL) " +
+                                       "OR ([value] = @Original_value)))",
+                                       cmd.CommandText, "#D1");
+                               Assert.AreEqual (4, cmd.Parameters.Count, "#D2");
+                       } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
                                ConnectionManager.Singleton.CloseConnection ();
                        }
                }
+#endif
 
                [Test]
-               public void DefaultPropertiesTest ()
+               public void DefaultProperties ()
                {
                        try {
                                ConnectionManager.Singleton.OpenConnection ();
@@ -425,10 +867,11 @@ namespace MonoTests.System.Data
                [Test]
                public void CheckParameters_BuiltCommand ()
                {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+
                        try {
-                               ConnectionManager.Singleton.OpenConnection ();
-                               IDbConnection conn = ConnectionManager.Singleton.Connection;
-                               SqlDataAdapter adapter = new SqlDataAdapter ("select id,type_varchar from string_family", (SqlConnection)conn);
+                               SqlDataAdapter adapter = new SqlDataAdapter ("select id,type_varchar from string_family", conn);
                                SqlCommandBuilder cb = new SqlCommandBuilder(adapter);
                                DataSet ds = new DataSet ();
                                adapter.Fill(ds);
@@ -448,20 +891,21 @@ namespace MonoTests.System.Data
                                ds.Tables[0].Rows.Add(row_rsInput);
 
                                Assert.AreEqual (2, cb.GetInsertCommand().Parameters.Count, "#3");
-                       }
-                       finally {
+                       } finally {
                                ConnectionManager.Singleton.CloseConnection ();
                        }
                }
 
                [Test]
-               public void DeriveParametersTest_Default ()
+               public void DeriveParameters ()
                {
-                       try {
-                               ConnectionManager.Singleton.OpenConnection ();
-                               SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
-                               SqlCommand cmd = new SqlCommand ();
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
 
+                       SqlCommand cmd = null;
+
+                       try {
+                               cmd = conn.CreateCommand ();
                                cmd.CommandText = "sp_326182";
                                cmd.CommandType = CommandType.StoredProcedure;
                                cmd.CommandTimeout = 90;
@@ -469,10 +913,830 @@ namespace MonoTests.System.Data
                                
                                SqlCommandBuilder.DeriveParameters (cmd);
                                Assert.AreEqual (5, cmd.Parameters.Count, "#4");
-                               
                        } finally {
-                               ConnectionManager.Singleton.CloseConnection ();
+                               if (cmd != null)
+                                       cmd.Dispose ();
+                               ConnectionManager.Singleton.CloseConnection ();
+                       }
+               }
+
+               [Test]
+               public void QuotePrefix_DeleteCommand_Generated ()
+               {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+
+                       SqlCommand cmd = null;
+
+                       try {
+                               string selectQuery = "select id, lname from employee where id = 3";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
+                               DataSet ds = new DataSet ();
+                               da.Fill (ds, "IntTest");
+
+                               SqlCommandBuilder cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetDeleteCommand ();
+#if NET_2_0
+                               Assert.AreEqual ("[", cb.QuotePrefix, "#1");
+#else
+                               Assert.AreEqual (string.Empty, cb.QuotePrefix, "#1");
+#endif
+                               try {
+                                       cb.QuotePrefix = "\"";
+                                       Assert.Fail ("#2");
+                               } catch (InvalidOperationException ex) {
+                                       // The QuotePrefix and QuoteSuffix properties
+                                       // cannot be changed once an Insert, Update, or
+                                       // Delete command has been generated
+                                       Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#3");
+                                       Assert.IsNull (ex.InnerException, "#4");
+                                       Assert.IsNotNull (ex.Message, "#5");
+                               }
+#if NET_2_0
+                               Assert.AreEqual ("[", cb.QuotePrefix, "#6");
+#else
+                               Assert.AreEqual (string.Empty, cb.QuotePrefix, "#6");
+#endif
+                               cb.RefreshSchema ();
+                               cb.QuotePrefix = "\"";
+                       } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
+                               ConnectionManager.Singleton.CloseConnection ();
+                       }
+               }
+
+               [Test]
+               public void QuotePrefix_InsertCommand_Generated ()
+               {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+
+                       SqlCommand cmd = null;
+
+                       try {
+                               string selectQuery = "select id, lname from employee where id = 3";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
+                               DataSet ds = new DataSet ();
+                               da.Fill (ds, "IntTest");
+
+                               SqlCommandBuilder cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetInsertCommand ();
+#if NET_2_0
+                               Assert.AreEqual ("[", cb.QuotePrefix, "#1");
+#else
+                               Assert.AreEqual (string.Empty, cb.QuotePrefix, "#1");
+#endif
+                               try {
+                                       cb.QuotePrefix = "\"";
+                                       Assert.Fail ("#2");
+                               } catch (InvalidOperationException ex) {
+                                       // The QuotePrefix and QuoteSuffix properties
+                                       // cannot be changed once an Insert, Update, or
+                                       // Delete command has been generated
+                                       Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#3");
+                                       Assert.IsNull (ex.InnerException, "#4");
+                                       Assert.IsNotNull (ex.Message, "#5");
+                               }
+#if NET_2_0
+                               Assert.AreEqual ("[", cb.QuotePrefix, "#6");
+#else
+                               Assert.AreEqual (string.Empty, cb.QuotePrefix, "#6");
+#endif
+                               cb.RefreshSchema ();
+                               cb.QuotePrefix = "\"";
+                       } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
+                               ConnectionManager.Singleton.CloseConnection ();
                        }
                }
+
+               [Test]
+               public void QuotePrefix_UpdateCommand_Generated ()
+               {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+
+                       SqlCommand cmd = null;
+
+                       try {
+                               string selectQuery = "select id, lname from employee where id = 3";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
+                               DataSet ds = new DataSet ();
+                               da.Fill (ds, "IntTest");
+
+                               SqlCommandBuilder cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetUpdateCommand ();
+#if NET_2_0
+                               Assert.AreEqual ("[", cb.QuotePrefix, "#1");
+#else
+                               Assert.AreEqual (string.Empty, cb.QuotePrefix, "#1");
+#endif
+                               try {
+                                       cb.QuotePrefix = "\"";
+                                       Assert.Fail ("#2");
+                               } catch (InvalidOperationException ex) {
+                                       // The QuotePrefix and QuoteSuffix properties
+                                       // cannot be changed once an Insert, Update, or
+                                       // Delete command has been generated
+                                       Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#3");
+                                       Assert.IsNull (ex.InnerException, "#4");
+                                       Assert.IsNotNull (ex.Message, "#5");
+                               }
+#if NET_2_0
+                               Assert.AreEqual ("[", cb.QuotePrefix, "#6");
+#else
+                               Assert.AreEqual (string.Empty, cb.QuotePrefix, "#6");
+#endif
+                               cb.RefreshSchema ();
+                               cb.QuotePrefix = "\"";
+                       } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
+                               ConnectionManager.Singleton.CloseConnection ();
+                       }
+               }
+
+               [Test]
+               public void QuoteSuffix_DeleteCommand_Generated ()
+               {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+
+                       SqlCommand cmd = null;
+
+                       try {
+                               string selectQuery = "select id, lname from employee where id = 3";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
+                               DataSet ds = new DataSet ();
+                               da.Fill (ds, "IntTest");
+
+                               SqlCommandBuilder cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetDeleteCommand ();
+#if NET_2_0
+                               Assert.AreEqual ("]", cb.QuoteSuffix, "#1");
+#else
+                               Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#1");
+#endif
+                               try {
+                                       cb.QuoteSuffix = "\"";
+                                       Assert.Fail ("#2");
+                               } catch (InvalidOperationException ex) {
+                                       // The QuotePrefix and QuoteSuffix properties
+                                       // cannot be changed once an Insert, Update, or
+                                       // Delete command has been generated
+                                       Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#3");
+                                       Assert.IsNull (ex.InnerException, "#4");
+                                       Assert.IsNotNull (ex.Message, "#5");
+                               }
+#if NET_2_0
+                               Assert.AreEqual ("]", cb.QuoteSuffix, "#6");
+#else
+                               Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#6");
+#endif
+                               cb.RefreshSchema ();
+                               cb.QuoteSuffix = "\"";
+                       } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
+                               ConnectionManager.Singleton.CloseConnection ();
+                       }
+               }
+
+               [Test]
+               public void QuoteSuffix_InsertCommand_Generated ()
+               {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+
+                       SqlCommand cmd = null;
+
+                       try {
+                               string selectQuery = "select id, lname from employee where id = 3";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
+                               DataSet ds = new DataSet ();
+                               da.Fill (ds, "IntTest");
+
+                               SqlCommandBuilder cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetInsertCommand ();
+#if NET_2_0
+                               Assert.AreEqual ("]", cb.QuoteSuffix, "#1");
+#else
+                               Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#1");
+#endif
+                               try {
+                                       cb.QuoteSuffix = "\"";
+                                       Assert.Fail ("#2");
+                               } catch (InvalidOperationException ex) {
+                                       // The QuotePrefix and QuoteSuffix properties
+                                       // cannot be changed once an Insert, Update, or
+                                       // Delete command has been generated
+                                       Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#3");
+                                       Assert.IsNull (ex.InnerException, "#4");
+                                       Assert.IsNotNull (ex.Message, "#5");
+                               }
+#if NET_2_0
+                               Assert.AreEqual ("]", cb.QuoteSuffix, "#6");
+#else
+                               Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#6");
+#endif
+                               cb.RefreshSchema ();
+                               cb.QuoteSuffix = "\"";
+                       } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
+                               ConnectionManager.Singleton.CloseConnection ();
+                       }
+               }
+
+               [Test]
+               public void QuoteSuffix_UpdateCommand_Generated ()
+               {
+                       SqlConnection conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+
+                       SqlCommand cmd = null;
+
+                       try {
+                               string selectQuery = "select id, lname from employee where id = 3";
+                               SqlDataAdapter da = new SqlDataAdapter (selectQuery, conn);
+                               DataSet ds = new DataSet ();
+                               da.Fill (ds, "IntTest");
+
+                               SqlCommandBuilder cb = new SqlCommandBuilder (da);
+                               cmd = cb.GetUpdateCommand ();
+#if NET_2_0
+                               Assert.AreEqual ("]", cb.QuoteSuffix, "#1");
+#else
+                               Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#1");
+#endif
+                               try {
+                                       cb.QuoteSuffix = "\"";
+                                       Assert.Fail ("#2");
+                               } catch (InvalidOperationException ex) {
+                                       // The QuotePrefix and QuoteSuffix properties
+                                       // cannot be changed once an Insert, Update, or
+                                       // Delete command has been generated
+                                       Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#3");
+                                       Assert.IsNull (ex.InnerException, "#4");
+                                       Assert.IsNotNull (ex.Message, "#5");
+                               }
+#if NET_2_0
+                               Assert.AreEqual ("]", cb.QuoteSuffix, "#6");
+#else
+                               Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#6");
+#endif
+                               cb.RefreshSchema ();
+                               cb.QuoteSuffix = "\"";
+                       } finally {
+                               if (cmd != null)
+                                       cmd.Dispose ();
+                               ConnectionManager.Singleton.CloseConnection ();
+                       }
+               }
+
+               static void AssertDeleteParameters (SqlCommand cmd, bool useColumnsForParameterNames, string prefix)
+               {
+                       SqlParameter param;
+
+#if NET_2_0
+                       Assert.AreEqual (4, cmd.Parameters.Count, prefix + "Count");
+#else
+                       Assert.AreEqual (5, cmd.Parameters.Count, prefix + "Count");
+#endif
+
+                       param = cmd.Parameters [0];
+                       Assert.AreEqual (DbType.Int32, param.DbType, prefix + "DbType (0)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (0)");
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (0)");
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (0)");
+                       if (useColumnsForParameterNames)
+                               Assert.AreEqual ("@Original_id", param.ParameterName, prefix + "ParameterName (0)");
+                       else
+                               Assert.AreEqual ("@p1", param.ParameterName, prefix + "ParameterName (0)");
+                       Assert.AreEqual (10, param.Precision, prefix + "Precision (0)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (0)");
+                       //Assert.AreEqual (0, param.Size, prefix + "Size (0)");
+                       Assert.AreEqual ("id", param.SourceColumn, prefix + "SourceColumn (0)");
+#if NET_2_0
+                       Assert.IsFalse (param.SourceColumnNullMapping, prefix + "SourceColumnNullMapping (0)");
+#endif
+                       Assert.AreEqual (DataRowVersion.Original, param.SourceVersion, prefix + "SourceVersion (0)");
+                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, prefix + "SqlDbType (0)");
+#if NET_2_0
+                       Assert.IsNull (param.SqlValue, prefix + "SqlValue (0)");
+                       //Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (0)");
+#endif
+                       Assert.IsNull (param.Value, prefix + "Value (0)");
+#if NET_2_0
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionDatabase, prefix + "XmlSchemaCollectionDatabase (0)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionName, prefix + "XmlSchemaCollectionName (0)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionOwningSchema, prefix + "XmlSchemaCollectionOwningSchema (0)");
+#endif
+
+#if ONLY_1_1
+                       param = cmd.Parameters [1];
+                       Assert.AreEqual (DbType.Int32, param.DbType, prefix + "DbType (1)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (1)");
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (1)");
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (1)");
+                       Assert.AreEqual ("@p2", param.ParameterName, prefix + "ParameterName (1)");
+                       Assert.AreEqual (0, param.Precision, prefix + "Precision (1)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (1)");
+                       //Assert.AreEqual (0, param.Size, prefix + "Size (1)");
+                       Assert.AreEqual (string.Empty, param.SourceColumn, prefix + "SourceColumn (1)");
+                       Assert.AreEqual (DataRowVersion.Current, param.SourceVersion, prefix + "SourceVersion (1)");
+                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, prefix + "SqlDbType (1)");
+                       Assert.AreEqual (1, param.Value, prefix + "Value (1)");
+#endif
+
+#if NET_2_0
+                       param = cmd.Parameters [1];
+#else
+                       param = cmd.Parameters [2];
+#endif
+                       Assert.AreEqual (DbType.AnsiString, param.DbType, prefix + "DbType (2)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (2)");
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (2)");
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (2)");
+#if NET_2_0
+                       if (useColumnsForParameterNames)
+                               Assert.AreEqual ("@Original_fname", param.ParameterName, prefix + "ParameterName (2)");
+                       else
+                               Assert.AreEqual ("@p2", param.ParameterName, prefix + "ParameterName (2)");
+#else
+                       Assert.AreEqual ("@p3", param.ParameterName, prefix + "ParameterName (2)");
+#endif
+                       Assert.AreEqual (0, param.Precision, prefix + "Precision (2)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (2)");
+                       Assert.AreEqual (0, param.Size, prefix + "Size (2)");
+                       Assert.AreEqual ("fname", param.SourceColumn, prefix + "SourceColumn (2)");
+#if NET_2_0
+                       Assert.IsFalse (param.SourceColumnNullMapping, prefix + "SourceColumnNullMapping (2)");
+#endif
+                       Assert.AreEqual (DataRowVersion.Original, param.SourceVersion, prefix + "SourceVersion (2)");
+                       Assert.AreEqual (SqlDbType.VarChar, param.SqlDbType, prefix + "SqlDbType (2)");
+#if NET_2_0
+                       Assert.IsNull (param.SqlValue, prefix + "SqlValue (2)");
+                       //Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (2)");
+#endif
+                       Assert.IsNull (param.Value, prefix + "Value (2)");
+#if NET_2_0
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionDatabase, prefix + "XmlSchemaCollectionDatabase (2)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionName, prefix + "XmlSchemaCollectionName (2)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionOwningSchema, prefix + "XmlSchemaCollectionOwningSchema (2)");
+#endif
+
+#if NET_2_0
+                       param = cmd.Parameters [2];
+#else
+                       param = cmd.Parameters [3];
+#endif
+                       Assert.AreEqual (DbType.Int32, param.DbType, prefix + "DbType (3)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (3)");
+#if NET_2_0
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (3)");
+#else
+                       Assert.IsTrue (param.IsNullable, prefix + "IsNullable (3)");
+#endif
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (3)");
+#if NET_2_0
+                       if (useColumnsForParameterNames)
+                               Assert.AreEqual ("@IsNull_lname", param.ParameterName, prefix + "ParameterName (3)");
+                       else
+                               Assert.AreEqual ("@p3", param.ParameterName, prefix + "ParameterName (3)");
+#else
+                       Assert.AreEqual ("@p4", param.ParameterName, prefix + "ParameterName (3)");
+#endif
+                       Assert.AreEqual (0, param.Precision, prefix + "Precision (3)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (3)");
+                       //Assert.AreEqual (0, param.Size, prefix + "Size (3)");
+#if NET_2_0
+                       Assert.AreEqual ("lname", param.SourceColumn, prefix + "SourceColumn (3)");
+                       Assert.IsTrue (param.SourceColumnNullMapping, prefix + "SourceColumnNullMapping (3)");
+                       Assert.AreEqual (DataRowVersion.Original, param.SourceVersion, prefix + "SourceVersion (3)");
+#else
+                       Assert.AreEqual (string.Empty, param.SourceColumn, prefix + "SourceColumn (3)");
+                       Assert.AreEqual (DataRowVersion.Current, param.SourceVersion, prefix + "SourceVersion (3)");
+#endif
+                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, prefix + "SqlDbType (3)");
+#if NET_2_0
+                       Assert.IsNotNull (param.SqlValue, prefix + "SqlValue (3)");
+                       Assert.AreEqual (typeof (SqlInt32), param.SqlValue.GetType (), prefix + "SqlValue (3)");
+                       Assert.AreEqual (1, ((SqlInt32) param.SqlValue).Value, prefix + "SqlValue (3)");
+                       //Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (3)");
+#endif
+                       Assert.AreEqual (1, param.Value, prefix + "Value (3)");
+#if NET_2_0
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionDatabase, prefix + "XmlSchemaCollectionDatabase (3)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionName, prefix + "XmlSchemaCollectionName (3)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionOwningSchema, prefix + "XmlSchemaCollectionOwningSchema (3)");
+#endif
+
+#if NET_2_0
+                       param = cmd.Parameters [3];
+#else
+                       param = cmd.Parameters [4];
+#endif
+                       Assert.AreEqual (DbType.AnsiString, param.DbType, prefix + "DbType (4)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (4)");
+#if NET_2_0
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (4)");
+#else
+                       Assert.IsTrue (param.IsNullable, prefix + "IsNullable (4)");
+#endif
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (4)");
+#if NET_2_0
+                       if (useColumnsForParameterNames)
+                               Assert.AreEqual ("@Original_lname", param.ParameterName, prefix + "ParameterName (4)");
+                       else
+                               Assert.AreEqual ("@p4", param.ParameterName, prefix + "ParameterName (4)");
+#else
+                       Assert.AreEqual ("@p5", param.ParameterName, prefix + "ParameterName (4)");
+#endif
+                       Assert.AreEqual (0, param.Precision, prefix + "Precision (4)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (4)");
+                       Assert.AreEqual (0, param.Size, prefix + "Size (4)");
+                       Assert.AreEqual ("lname", param.SourceColumn, prefix + "SourceColumn (4)");
+#if NET_2_0
+                       Assert.IsFalse (param.SourceColumnNullMapping, prefix + "SourceColumnNullMapping (4)");
+#endif
+                       Assert.AreEqual (DataRowVersion.Original, param.SourceVersion, prefix + "SourceVersion (4)");
+                       Assert.AreEqual (SqlDbType.VarChar, param.SqlDbType, prefix + "SqlDbType (4)");
+#if NET_2_0
+                       Assert.IsNull (param.SqlValue, prefix + "SqlValue (4)");
+                       //Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (4)");
+#endif
+                       Assert.IsNull (param.Value, prefix + "Value (4)");
+#if NET_2_0
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionDatabase, prefix + "XmlSchemaCollectionDatabase (4)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionName, prefix + "XmlSchemaCollectionName (4)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionOwningSchema, prefix + "XmlSchemaCollectionOwningSchema (4)");
+#endif
+               }
+
+               static void AssertInsertParameters (SqlCommand cmd, bool useColumnsForParameterNames, string prefix)
+               {
+                       SqlParameter param;
+
+                       Assert.AreEqual (3, cmd.Parameters.Count, prefix + "Count");
+
+                       param = cmd.Parameters [0];
+                       Assert.AreEqual (DbType.Int32, param.DbType, prefix + "DbType (0)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (0)");
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (0)");
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (0)");
+                       if (useColumnsForParameterNames)
+                               Assert.AreEqual ("@id", param.ParameterName, prefix + "ParameterName (0)");
+                       else
+                               Assert.AreEqual ("@p1", param.ParameterName, prefix + "ParameterName (0)");
+                       Assert.AreEqual (10, param.Precision, prefix + "Precision (0)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (0)");
+                       //Assert.AreEqual (0, param.Size, prefix + "Size (0)");
+                       Assert.AreEqual ("id", param.SourceColumn, prefix + "SourceColumn (0)");
+#if NET_2_0
+                       Assert.IsFalse (param.SourceColumnNullMapping, prefix + "SourceColumnNullMapping (0)");
+#endif
+                       Assert.AreEqual (DataRowVersion.Current, param.SourceVersion, prefix + "SourceVersion (0)");
+                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, prefix + "SqlDbType (0)");
+#if NET_2_0
+                       Assert.IsNull (param.SqlValue, prefix + "SqlValue (0)");
+                       //Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (0)");
+#endif
+                       Assert.IsNull (param.Value, prefix + "Value (0)");
+#if NET_2_0
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionDatabase, prefix + "XmlSchemaCollectionDatabase (0)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionName, prefix + "XmlSchemaCollectionName (0)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionOwningSchema, prefix + "XmlSchemaCollectionOwningSchema (0)");
+#endif
+
+                       param = cmd.Parameters [1];
+                       Assert.AreEqual (DbType.AnsiString, param.DbType, prefix + "DbType (1)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (1)");
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (1)");
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (1)");
+                       if (useColumnsForParameterNames)
+                               Assert.AreEqual ("@fname", param.ParameterName, prefix + "ParameterName (1)");
+                       else
+                               Assert.AreEqual ("@p2", param.ParameterName, prefix + "ParameterName (1)");
+                       Assert.AreEqual (0, param.Precision, prefix + "Precision (1)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (1)");
+                       Assert.AreEqual (0, param.Size, prefix + "Size (1)");
+                       Assert.AreEqual ("fname", param.SourceColumn, prefix + "SourceColumn (1)");
+#if NET_2_0
+                       Assert.IsFalse (param.SourceColumnNullMapping, prefix + "SourceColumnNullMapping (1)");
+#endif
+                       Assert.AreEqual (DataRowVersion.Current, param.SourceVersion, prefix + "SourceVersion (1)");
+                       Assert.AreEqual (SqlDbType.VarChar, param.SqlDbType, prefix + "SqlDbType (1)");
+#if NET_2_0
+                       Assert.IsNull (param.SqlValue, prefix + "SqlValue (1)");
+                       //Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (1)");
+#endif
+                       Assert.IsNull (param.Value, prefix + "Value (1)");
+#if NET_2_0
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionDatabase, prefix + "XmlSchemaCollectionDatabase (1)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionName, prefix + "XmlSchemaCollectionName (1)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionOwningSchema, prefix + "XmlSchemaCollectionOwningSchema (1)");
+#endif
+
+                       param = cmd.Parameters [2];
+                       Assert.AreEqual (DbType.AnsiString, param.DbType, prefix + "DbType (2)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (2)");
+#if NET_2_0
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (2)");
+#else
+                       Assert.IsTrue (param.IsNullable, prefix + "IsNullable (2)");
+#endif
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (2)");
+                       if (useColumnsForParameterNames)
+                               Assert.AreEqual ("@lname", param.ParameterName, prefix + "ParameterName (2)");
+                       else
+                               Assert.AreEqual ("@p3", param.ParameterName, prefix + "ParameterName (2)");
+                       Assert.AreEqual (0, param.Precision, prefix + "Precision (2)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (2)");
+                       Assert.AreEqual (0, param.Size, prefix + "Size (2)");
+                       Assert.AreEqual ("lname", param.SourceColumn, prefix + "SourceColumn (2)");
+#if NET_2_0
+                       Assert.IsFalse (param.SourceColumnNullMapping, prefix + "SourceColumnNullMapping (2)");
+#endif
+                       Assert.AreEqual (DataRowVersion.Current, param.SourceVersion, prefix + "SourceVersion (2)");
+                       Assert.AreEqual (SqlDbType.VarChar, param.SqlDbType, prefix + "SqlDbType (2)");
+#if NET_2_0
+                       Assert.IsNull (param.SqlValue, prefix + "SqlValue (2)");
+                       //Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (2)");
+#endif
+                       Assert.IsNull (param.Value, prefix + "Value (2)");
+#if NET_2_0
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionDatabase, prefix + "XmlSchemaCollectionDatabase (2)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionName, prefix + "XmlSchemaCollectionName (2)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionOwningSchema, prefix + "XmlSchemaCollectionOwningSchema (2)");
+#endif
+               }
+
+               static void AssertUpdateParameters (SqlCommand cmd, bool useColumnsForParameterNames, string prefix)
+               {
+                       SqlParameter param;
+
+#if NET_2_0
+                       Assert.AreEqual (7, cmd.Parameters.Count, prefix + "Count");
+#else
+                       Assert.AreEqual (8, cmd.Parameters.Count, prefix + "Count");
+#endif
+
+                       param = cmd.Parameters [0];
+                       Assert.AreEqual (DbType.Int32, param.DbType, prefix + "DbType (0)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (0)");
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (0)");
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (0)");
+                       if (useColumnsForParameterNames)
+                               Assert.AreEqual ("@id", param.ParameterName, prefix + "ParameterName (0)");
+                       else
+                               Assert.AreEqual ("@p1", param.ParameterName, prefix + "ParameterName (0)");
+                       Assert.AreEqual (10, param.Precision, prefix + "Precision (0)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (0)");
+                       //Assert.AreEqual (0, param.Size, prefix + "Size (0)");
+                       Assert.AreEqual ("id", param.SourceColumn, prefix + "SourceColumn (0)");
+#if NET_2_0
+                       Assert.IsFalse (param.SourceColumnNullMapping, prefix + "SourceColumnNullMapping (0)");
+#endif
+                       Assert.AreEqual (DataRowVersion.Current, param.SourceVersion, prefix + "SourceVersion (0)");
+                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, prefix + "SqlDbType (0)");
+#if NET_2_0
+                       Assert.IsNull (param.SqlValue, prefix + "SqlValue (0)");
+                       //Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (0)");
+#endif
+                       Assert.IsNull (param.Value, prefix + "Value (0)");
+#if NET_2_0
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionDatabase, prefix + "XmlSchemaCollectionDatabase (0)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionName, prefix + "XmlSchemaCollectionName (0)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionOwningSchema, prefix + "XmlSchemaCollectionOwningSchema (0)");
+#endif
+
+                       param = cmd.Parameters [1];
+                       Assert.AreEqual (DbType.AnsiString, param.DbType, prefix + "DbType (1)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (1)");
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (1)");
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (1)");
+                       if (useColumnsForParameterNames)
+                               Assert.AreEqual ("@fname", param.ParameterName, prefix + "ParameterName (1)");
+                       else
+                               Assert.AreEqual ("@p2", param.ParameterName, prefix + "ParameterName (1)");
+                       Assert.AreEqual (0, param.Precision, prefix + "Precision (1)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (1)");
+                       //Assert.AreEqual (0, param.Size, prefix + "Size (1)");
+                       Assert.AreEqual ("fname", param.SourceColumn, prefix + "SourceColumn (1)");
+#if NET_2_0
+                       Assert.IsFalse (param.SourceColumnNullMapping, prefix + "SourceColumnNullMapping (1)");
+#endif
+                       Assert.AreEqual (DataRowVersion.Current, param.SourceVersion, prefix + "SourceVersion (1)");
+                       Assert.AreEqual (SqlDbType.VarChar, param.SqlDbType, prefix + "SqlDbType (1)");
+#if NET_2_0
+                       Assert.IsNull (param.SqlValue, prefix + "SqlValue (1)");
+                       //Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (1)");
+#endif
+                       Assert.IsNull (param.Value, prefix + "Value (1)");
+#if NET_2_0
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionDatabase, prefix + "XmlSchemaCollectionDatabase (1)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionName, prefix + "XmlSchemaCollectionName (1)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionOwningSchema, prefix + "XmlSchemaCollectionOwningSchema (1)");
+#endif
+
+                       param = cmd.Parameters [2];
+                       Assert.AreEqual (DbType.AnsiString, param.DbType, prefix + "DbType (2)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (2)");
+#if NET_2_0
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (2)");
+#else
+                       Assert.IsTrue (param.IsNullable, prefix + "IsNullable (2)");
+#endif
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (2)");
+                       if (useColumnsForParameterNames)
+                               Assert.AreEqual ("@lname", param.ParameterName, prefix + "ParameterName (2)");
+                       else
+                               Assert.AreEqual ("@p3", param.ParameterName, prefix + "ParameterName (2)");
+                       Assert.AreEqual (0, param.Precision, prefix + "Precision (2)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (2)");
+                       Assert.AreEqual (0, param.Size, prefix + "Size (2)");
+                       Assert.AreEqual ("lname", param.SourceColumn, prefix + "SourceColumn (2)");
+#if NET_2_0
+                       Assert.IsFalse (param.SourceColumnNullMapping, prefix + "SourceColumnNullMapping (2)");
+#endif
+                       Assert.AreEqual (DataRowVersion.Current, param.SourceVersion, prefix + "SourceVersion (2)");
+                       Assert.AreEqual (SqlDbType.VarChar, param.SqlDbType, prefix + "SqlDbType (2)");
+#if NET_2_0
+                       Assert.IsNull (param.SqlValue, prefix + "SqlValue (2)");
+                       //Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (2)");
+#endif
+                       Assert.IsNull (param.Value, prefix + "Value (2)");
+#if NET_2_0
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionDatabase, prefix + "XmlSchemaCollectionDatabase (2)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionName, prefix + "XmlSchemaCollectionName (2)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionOwningSchema, prefix + "XmlSchemaCollectionOwningSchema (2)");
+#endif
+
+                       param = cmd.Parameters [3];
+                       Assert.AreEqual (DbType.Int32, param.DbType, prefix + "DbType (3)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (3)");
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (3)");
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (3)");
+                       if (useColumnsForParameterNames)
+                               Assert.AreEqual ("@Original_id", param.ParameterName, prefix + "ParameterName (3)");
+                       else
+                               Assert.AreEqual ("@p4", param.ParameterName, prefix + "ParameterName (3)");
+                       Assert.AreEqual (10, param.Precision, prefix + "Precision (3)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (3)");
+                       //Assert.AreEqual (0, param.Size, prefix + "Size (3)");
+                       Assert.AreEqual ("id", param.SourceColumn, prefix + "SourceColumn (3)");
+#if NET_2_0
+                       Assert.IsFalse (param.SourceColumnNullMapping, prefix + "SourceColumnNullMapping (3)");
+#endif
+                       Assert.AreEqual (DataRowVersion.Original, param.SourceVersion, prefix + "SourceVersion (3)");
+                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, prefix + "SqlDbType (3)");
+#if NET_2_0
+                       Assert.IsNull (param.SqlValue, prefix + "SqlValue (3)");
+                       //Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (3)");
+#endif
+                       Assert.IsNull (param.Value, prefix + "Value (3)");
+#if NET_2_0
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionDatabase, prefix + "XmlSchemaCollectionDatabase (3)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionName, prefix + "XmlSchemaCollectionName (3)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionOwningSchema, prefix + "XmlSchemaCollectionOwningSchema (3)");
+#endif
+
+#if ONLY_1_1
+                       param = cmd.Parameters [4];
+                       Assert.AreEqual (DbType.Int32, param.DbType, prefix + "DbType (4)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (4)");
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (4)");
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (4)");
+                       Assert.AreEqual ("@p5", param.ParameterName, prefix + "ParameterName (4)");
+                       Assert.AreEqual (0, param.Precision, prefix + "Precision (4)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (4)");
+                       //Assert.AreEqual (0, param.Size, prefix + "Size (4)");
+                       Assert.AreEqual (string.Empty, param.SourceColumn, prefix + "SourceColumn (4)");
+                       Assert.AreEqual (DataRowVersion.Current, param.SourceVersion, prefix + "SourceVersion (4)");
+                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, prefix + "SqlDbType (4)");
+                       Assert.AreEqual (1, param.Value, prefix + "Value (4)");
+#endif
+
+#if NET_2_0
+                       param = cmd.Parameters [4];
+#else
+                       param = cmd.Parameters [5];
+#endif
+                       Assert.AreEqual (DbType.AnsiString, param.DbType, prefix + "DbType (5)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (5)");
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (5)");
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (5)");
+                       if (useColumnsForParameterNames)
+                               Assert.AreEqual ("@Original_fname", param.ParameterName, prefix + "ParameterName (5)");
+                       else
+#if NET_2_0
+                               Assert.AreEqual ("@p5", param.ParameterName, prefix + "ParameterName (5)");
+#else
+                               Assert.AreEqual ("@p6", param.ParameterName, prefix + "ParameterName (5)");
+#endif
+                       Assert.AreEqual (0, param.Precision, prefix + "Precision (5)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (5)");
+                       Assert.AreEqual (0, param.Size, prefix + "Size (5)");
+                       Assert.AreEqual ("fname", param.SourceColumn, prefix + "SourceColumn (5)");
+#if NET_2_0
+                       Assert.IsFalse (param.SourceColumnNullMapping, prefix + "SourceColumnNullMapping (5)");
+#endif
+                       Assert.AreEqual (DataRowVersion.Original, param.SourceVersion, prefix + "SourceVersion (5)");
+                       Assert.AreEqual (SqlDbType.VarChar, param.SqlDbType, prefix + "SqlDbType (5)");
+#if NET_2_0
+                       Assert.IsNull (param.SqlValue, prefix + "SqlValue (5)");
+                       //Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (5)");
+#endif
+                       Assert.IsNull (param.Value, prefix + "Value (5)");
+#if NET_2_0
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionDatabase, prefix + "XmlSchemaCollectionDatabase (5)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionName, prefix + "XmlSchemaCollectionName (5)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionOwningSchema, prefix + "XmlSchemaCollectionOwningSchema (5)");
+#endif
+
+#if NET_2_0
+                       param = cmd.Parameters [5];
+#else
+                       param = cmd.Parameters [6];
+#endif
+                       Assert.AreEqual (DbType.Int32, param.DbType, prefix + "DbType (6)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (6)");
+#if NET_2_0
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (6)");
+#else
+                       Assert.IsTrue (param.IsNullable, prefix + "IsNullable (6)");
+#endif
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (6)");
+                       if (useColumnsForParameterNames)
+                               Assert.AreEqual ("@IsNull_lname", param.ParameterName, prefix + "ParameterName (6)");
+                       else
+#if NET_2_0
+                               Assert.AreEqual ("@p6", param.ParameterName, prefix + "ParameterName (6)");
+#else
+                               Assert.AreEqual ("@p7", param.ParameterName, prefix + "ParameterName (6)");
+#endif
+                       Assert.AreEqual (0, param.Precision, prefix + "Precision (6)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (6)");
+                       //Assert.AreEqual (0, param.Size, prefix + "Size (6)");
+#if NET_2_0
+                       Assert.AreEqual ("lname", param.SourceColumn, prefix + "SourceColumn (6)");
+                       Assert.IsTrue (param.SourceColumnNullMapping, prefix + "SourceColumnNullMapping (6)");
+                       Assert.AreEqual (DataRowVersion.Original, param.SourceVersion, prefix + "SourceVersion (6)");
+#else
+                       Assert.AreEqual (string.Empty, param.SourceColumn, prefix + "SourceColumn (6)");
+                       Assert.AreEqual (DataRowVersion.Current, param.SourceVersion, prefix + "SourceVersion (6)");
+#endif
+                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, prefix + "SqlDbType (6)");
+#if NET_2_0
+                       Assert.IsNotNull (param.SqlValue, prefix + "SqlValue (6)");
+                       Assert.AreEqual (typeof (SqlInt32), param.SqlValue.GetType (), prefix + "SqlValue (6)");
+                       Assert.AreEqual (1, ((SqlInt32) param.SqlValue).Value, prefix + "SqlValue (6)");
+                       //Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (6)");
+#endif
+                       Assert.AreEqual (1, param.Value, prefix + "Value (6)");
+#if NET_2_0
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionDatabase, prefix + "XmlSchemaCollectionDatabase (6)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionName, prefix + "XmlSchemaCollectionName (6)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionOwningSchema, prefix + "XmlSchemaCollectionOwningSchema (6)");
+#endif
+
+#if NET_2_0
+                       param = cmd.Parameters [6];
+#else
+                       param = cmd.Parameters [7];
+#endif
+                       Assert.AreEqual (DbType.AnsiString, param.DbType, prefix + "DbType (7)");
+                       Assert.AreEqual (ParameterDirection.Input, param.Direction, prefix + "Direction (7)");
+#if NET_2_0
+                       Assert.IsFalse (param.IsNullable, prefix + "IsNullable (7)");
+#else
+                       Assert.IsTrue (param.IsNullable, prefix + "IsNullable (7)");
+#endif
+                       Assert.AreEqual (0, param.Offset, prefix + "Offset (7)");
+                       if (useColumnsForParameterNames)
+                               Assert.AreEqual ("@Original_lname", param.ParameterName, prefix + "ParameterName (7)");
+                       else
+#if NET_2_0
+                               Assert.AreEqual ("@p7", param.ParameterName, prefix + "ParameterName (7)");
+#else
+                               Assert.AreEqual ("@p8", param.ParameterName, prefix + "ParameterName (7)");
+#endif
+                       Assert.AreEqual (0, param.Precision, prefix + "Precision (7)");
+                       Assert.AreEqual (0, param.Scale, prefix + "Scale (7)");
+                       Assert.AreEqual (0, param.Size, prefix + "Size (7)");
+                       Assert.AreEqual ("lname", param.SourceColumn, prefix + "SourceColumn (7)");
+#if NET_2_0
+                       Assert.IsFalse (param.SourceColumnNullMapping, prefix + "SourceColumnNullMapping (7)");
+#endif
+                       Assert.AreEqual (DataRowVersion.Original, param.SourceVersion, prefix + "SourceVersion (7)");
+                       Assert.AreEqual (SqlDbType.VarChar, param.SqlDbType, prefix + "SqlDbType (7)");
+#if NET_2_0
+                       Assert.IsNull (param.SqlValue, prefix + "SqlValue (7)");
+                       //Assert.AreEqual (string.Empty, param.UdtTypeName, prefix + "UdtTypeName (7)");
+#endif
+                       Assert.IsNull (param.Value, prefix + "Value (7)");
+#if NET_2_0
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionDatabase, prefix + "XmlSchemaCollectionDatabase (7)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionName, prefix + "XmlSchemaCollectionName (7)");
+                       Assert.AreEqual (string.Empty, param.XmlSchemaCollectionOwningSchema, prefix + "XmlSchemaCollectionOwningSchema (7)");
+#endif
+               }
        }
 }
index 99325838769bf237119ca81c7c02b204173a9786..afd5cef4b404674a694346d610d6d71b431ead4d 100644 (file)
@@ -1517,7 +1517,7 @@ namespace MonoTests.System.Data.SqlClient
                                try {
                                        cmd.ExecuteNonQuery ();
                                        Assert.Fail ("#B1");
-                               } catch (SqlException ex) {
+                               } catch (SqlException) {
                                        // Procedure or Function '#sp_temp_insert_employee'
                                        // expects parameter '@fname', which was not supplied
                                }
index feec0c6620dac1f90ef8aa7750e3fcf35a19b096..7dbe0f6e2cdfe92281a2bed533283ebd09127d81 100644 (file)
@@ -824,12 +824,6 @@ namespace MonoTests.System.Data
                        return connection_count;
                }
 #endif
-
-               static bool RunningOnMono {
-                       get {
-                               return (Type.GetType ("System.MonoType", false) != null);
-                       }
-               }
        }
 
 #if NET_2_0
index 4f700ab6c4e0d3196ea96ba9e6b409b37e21689e..c6eb98b7ac6126eb2f62b5edc24627c761cc7460 100644 (file)
@@ -878,12 +878,6 @@ namespace MonoTests.System.Data.SqlClient
                [Test]
                public void GetChars ()
                {
-#if ONLY_1_1
-                       // FIXME
-                       if (RunningOnMono)
-                               Assert.Ignore ("HANGS!!!");
-#endif
-
                        cmd.CommandText = "Select type_char, type_varchar,type_text, type_ntext ";
                        cmd.CommandText += "from string_family where id=1";
                        reader = cmd.ExecuteReader ();
@@ -1057,19 +1051,6 @@ namespace MonoTests.System.Data.SqlClient
                        reader.Close ();
                }
 
-               [Test]
-               public void GetSqlValueTest ()
-               {
-                       cmd.CommandText = "Select id, type_tinyint, null from numeric_family where id=1";
-                       reader = cmd.ExecuteReader ();
-                       reader.Read ();
-
-                       Assert.AreEqual ((byte)255, ((SqlByte) reader.GetSqlValue(1)).Value, "#1");
-                       //Assert.AreEqual (DBNull.Value, reader.GetSqlValue(2), "#2");
-
-                       reader.Close ();
-               }
-
                [Test]
                public void GetValuesTest ()
                {
@@ -1096,6 +1077,120 @@ namespace MonoTests.System.Data.SqlClient
                        reader.Close ();
                }
 
+               [Test]
+               public void GetValues_Values_Null ()
+               {
+                       cmd.CommandText = "SELECT type_blob FROM binary_family where id = 1";
+
+                       using (IDataReader rdr = cmd.ExecuteReader ()) {
+                               Assert.IsTrue (rdr.Read ());
+
+                               try {
+                                       rdr.GetValues ((object []) null);
+                                       Assert.Fail ("#1");
+                               } catch (ArgumentNullException ex) {
+                                       Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+                                       Assert.IsNull (ex.InnerException, "#3");
+                                       Assert.IsNotNull (ex.Message, "#4");
+                                       Assert.AreEqual ("values", ex.ParamName, "#5");
+                               }
+                       }
+               }
+
+               [Test]
+               public void GetSqlValue ()
+               {
+                       cmd.CommandText = "Select id, type_tinyint, null from numeric_family where id=1";
+                       reader = cmd.ExecuteReader ();
+                       reader.Read ();
+
+                       Assert.AreEqual ((byte) 255, ((SqlByte) reader.GetSqlValue (1)).Value, "#1");
+                       //Assert.AreEqual (DBNull.Value, reader.GetSqlValue(2), "#2");
+
+                       reader.Close ();
+               }
+
+               [Test]
+               public void GetSqlValue_Index_Invalid ()
+               {
+                       cmd.CommandText = "Select id, type_tinyint, null from numeric_family where id=1";
+                       reader = cmd.ExecuteReader ();
+                       reader.Read ();
+
+                       try {
+                               reader.GetSqlValue (-1);
+                               Assert.Fail ("#A1");
+                       } catch (IndexOutOfRangeException ex) {
+                               // Index was outside the bounds of the array
+                               Assert.AreEqual (typeof (IndexOutOfRangeException), ex.GetType (), "#A2");
+                               Assert.IsNull (ex.InnerException, "#A3");
+                               Assert.IsNotNull (ex.Message, "#A4");
+                       }
+
+                       try {
+                               reader.GetSqlValue (3);
+                               Assert.Fail ("#B1");
+                       } catch (IndexOutOfRangeException ex) {
+                               // Index was outside the bounds of the array
+                               Assert.AreEqual (typeof (IndexOutOfRangeException), ex.GetType (), "#B2");
+                               Assert.IsNull (ex.InnerException, "#B3");
+                               Assert.IsNotNull (ex.Message, "#B4");
+                       }
+               }
+
+               [Test]
+               public void GetSqlValue_Reader_Closed ()
+               {
+                       SqlCommand cmd = conn.CreateCommand ();
+                       cmd.CommandText = "SELECT * FROM employee";
+                       using (SqlDataReader rdr = cmd.ExecuteReader ()) {
+                               rdr.Read ();
+                               rdr.Close ();
+                               try {
+                                       rdr.GetSqlValue (-1);
+                                       Assert.Fail ("#1");
+                               } catch (InvalidOperationException ex) {
+                                       // Invalid attempt to call MetaData
+                                       // when reader is closed
+                                       Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
+                                       Assert.IsNull (ex.InnerException, "#3");
+                                       Assert.IsNotNull (ex.Message, "#4");
+                               }
+                       }
+               }
+
+               [Test]
+               public void GetSqlValue_Reader_NoData ()
+               {
+                       SqlCommand cmd = conn.CreateCommand ();
+                       cmd.CommandText = "SELECT * FROM employee where id = 6666";
+                       using (SqlDataReader rdr = cmd.ExecuteReader ()) {
+                               try {
+                                       rdr.GetSqlValue (-1);
+                                       Assert.Fail ("#A1");
+                               } catch (InvalidOperationException ex) {
+                                       // Invalid attempt to read when no data
+                                       // is present
+                                       Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
+                                       Assert.IsNull (ex.InnerException, "#A3");
+                                       Assert.IsNotNull (ex.Message, "#A4");
+                               }
+
+                               Assert.IsFalse (rdr.Read (), "#B");
+
+                               try {
+                                       rdr.GetSqlValue (-1);
+                                       Assert.Fail ("#C1");
+                               } catch (InvalidOperationException ex) {
+                                       // Invalid attempt to read when no data
+                                       // is present
+                                       Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#C2");
+                                       Assert.IsNull (ex.InnerException, "#C3");
+                                       Assert.IsNotNull (ex.Message, "#C4");
+                               }
+                       }
+               }
+
                [Test]
                public void GetSqlValues ()
                {
@@ -1161,17 +1256,17 @@ namespace MonoTests.System.Data.SqlClient
                                        Assert.IsNotNull (ex.Message, "#A4");
                                }
 
-                               Assert.IsFalse (rdr.Read (), "B");
+                               Assert.IsFalse (rdr.Read (), "#B");
 
                                try {
                                        rdr.GetSqlValues (null);
-                                       Assert.Fail ("#B1");
+                                       Assert.Fail ("#C1");
                                } catch (InvalidOperationException ex) {
                                        // Invalid attempt to read when no data
                                        // is present
-                                       Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
-                                       Assert.IsNull (ex.InnerException, "#B3");
-                                       Assert.IsNotNull (ex.Message, "#B4");
+                                       Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#C2");
+                                       Assert.IsNull (ex.InnerException, "#C3");
+                                       Assert.IsNotNull (ex.Message, "#C4");
                                }
                        }
                }
@@ -1205,45 +1300,127 @@ namespace MonoTests.System.Data.SqlClient
                                try {
                                        rdr.GetValue (0);
                                        Assert.Fail ("#A2");
-                               } catch (InvalidOperationException ex) {
-                                       // Invalid attempt to read when no data
-                                       // is present
-                                       Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A3");
-                                       Assert.IsNull (ex.InnerException, "#A4");
-                                       Assert.IsNotNull (ex.Message, "#A5");
+                               } catch (InvalidOperationException) {
                                }
-
-                               Assert.IsTrue (rdr.HasRows, "#B1");
-                               Assert.IsTrue (rdr.Read (), "#B2");
-                               Assert.AreEqual (1, rdr.GetValue (0), "#B3");
-                               Assert.IsTrue (rdr.HasRows, "#B4");
-                               Assert.IsTrue (rdr.Read (), "#B5");
-                               Assert.AreEqual (2, rdr.GetValue (0), "#B6");
-                               Assert.IsTrue (rdr.HasRows, "#B7");
-                               Assert.IsFalse (rdr.Read (), "#B8");
-                               Assert.IsTrue (rdr.HasRows, "#B9");
-                               Assert.IsFalse (rdr.NextResult (), "#B10");
-                               Assert.IsFalse (rdr.HasRows, "#B11");
+                               Assert.IsTrue (rdr.HasRows, "#A3");
+                               Assert.IsTrue (rdr.Read (), "#A4");
+                               Assert.AreEqual (1, rdr.GetValue (0), "#A5");
+                               Assert.IsTrue (rdr.HasRows, "#A6");
+                               Assert.AreEqual (1, rdr.GetValue (0), "#A7");
+                               Assert.IsTrue (rdr.Read (), "#A8");
+                               Assert.AreEqual (2, rdr.GetValue (0), "#A9");
+                               Assert.IsTrue (rdr.HasRows, "#A10");
+                               Assert.IsFalse (rdr.Read (), "#A11");
+                               Assert.IsTrue (rdr.HasRows, "#A12");
+                               Assert.IsFalse (rdr.NextResult (), "#A13");
+                               Assert.IsFalse (rdr.HasRows, "#A14");
                        }
 
                        cmd.CommandText = "SELECT id FROM employee WHERE id = 666";
+                       using (SqlDataReader rdr = cmd.ExecuteReader ()) {
+                               Assert.IsFalse (rdr.HasRows, "#B1");
+                               Assert.IsFalse (rdr.Read (), "#B2");
+                       }
+
+                       cmd.CommandText = "SELECT id FROM employee WHERE id = 666; SELECT 3";
                        using (SqlDataReader rdr = cmd.ExecuteReader ()) {
                                Assert.IsFalse (rdr.HasRows, "#C1");
                                Assert.IsFalse (rdr.Read (), "#C2");
+                               Assert.IsFalse (rdr.HasRows, "#C3");
+                               Assert.IsTrue (rdr.NextResult (), "#C4");
+                               Assert.IsTrue (rdr.HasRows, "#C5");
+                               try {
+                                       rdr.GetValue (0);
+                                       Assert.Fail ("#C6");
+                               } catch (InvalidOperationException) {
+                               }
+                               Assert.IsTrue (rdr.Read (), "#C7");
+                               Assert.AreEqual (3, rdr.GetValue (0), "#C8");
+                               Assert.IsTrue (rdr.HasRows, "#C9");
+                               Assert.AreEqual (3, rdr.GetValue (0), "#C10");
+                               Assert.IsFalse (rdr.Read (), "#C11");
+                               Assert.IsTrue (rdr.HasRows, "#C12");
+                               try {
+                                       rdr.GetValue (0);
+                                       Assert.Fail ("#C13");
+                               } catch (InvalidOperationException) {
+                               }
+                               Assert.IsFalse (rdr.NextResult (), "#C14");
+                               Assert.IsFalse (rdr.HasRows, "#C15");
+                               Assert.IsFalse (rdr.Read (), "#C16");
+                               Assert.IsFalse (rdr.HasRows, "#C17");
+                       }
+
+                       cmd.CommandText = "SELECT id FROM employee WHERE id = 1; SELECT 3";
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.SingleResult)) {
+                               Assert.IsTrue (rdr.HasRows, "#D1");
+                               Assert.IsTrue (rdr.Read (), "#D2");
+                               Assert.IsTrue (rdr.HasRows, "#D3");
+                               Assert.IsFalse (rdr.NextResult (), "#D4");
+                               Assert.IsFalse (rdr.HasRows, "#D5");
+                               Assert.IsFalse (rdr.Read (), "#D6");
+                               Assert.IsFalse (rdr.HasRows, "#D7");
                        }
 
                        cmd.CommandText = "SELECT id FROM employee WHERE id = 666; SELECT 3";
-                       using (SqlDataReader rdr = cmd.ExecuteReader ()) {
-                               Assert.IsFalse (rdr.HasRows, "#D1");
-                               Assert.IsFalse (rdr.Read (), "#D2");
-                               Assert.IsFalse (rdr.HasRows, "#D3");
-                               Assert.IsTrue (rdr.NextResult (), "#D4");
-                               Assert.IsTrue (rdr.HasRows, "#D5");
-                               Assert.IsTrue (rdr.Read (), "#D6");
-                               Assert.AreEqual (3, rdr.GetValue (0), "#D7");
-                               Assert.IsTrue (rdr.HasRows, "#D8");
-                               Assert.IsFalse (rdr.Read (), "#D9");
-                               Assert.IsTrue (rdr.HasRows, "#D10");
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.SingleResult)) {
+                               Assert.IsFalse (rdr.HasRows, "#E1");
+                               Assert.IsFalse (rdr.Read (), "#E2");
+                               Assert.IsFalse (rdr.HasRows, "#E3");
+                               Assert.IsFalse (rdr.NextResult (), "#E4");
+                               Assert.IsFalse (rdr.HasRows, "#E5");
+                               Assert.IsFalse (rdr.Read (), "#E6");
+                               Assert.IsFalse (rdr.HasRows, "#E7");
+                       }
+
+                       cmd.CommandText = "SELECT id FROM employee WHERE id = 1; SELECT 3";
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.SchemaOnly)) {
+                               Assert.IsFalse (rdr.HasRows, "#F1");
+                               try {
+                                       rdr.GetValue (0);
+                                       Assert.Fail ("#F2");
+                               } catch (InvalidOperationException) {
+                               }
+                               Assert.IsFalse (rdr.Read (), "#F3");
+                               try {
+                                       rdr.GetValue (0);
+                                       Assert.Fail ("#F4");
+                               } catch (InvalidOperationException) {
+                               }
+                               Assert.IsFalse (rdr.HasRows, "#F5");
+                               try {
+                                       rdr.GetValue (0);
+                                       Assert.Fail ("#F6");
+                               } catch (InvalidOperationException) {
+                               }
+                               Assert.IsTrue (rdr.NextResult (), "#F7");
+                               try {
+                                       rdr.GetValue (0);
+                                       Assert.Fail ("#F8");
+                               } catch (InvalidOperationException) {
+                               }
+                               Assert.IsFalse (rdr.HasRows, "#F9");
+                               Assert.IsFalse (rdr.Read (), "#F10");
+                               Assert.IsFalse (rdr.HasRows, "#F11");
+                               Assert.IsFalse (rdr.NextResult (), "#F12");
+                               Assert.IsFalse (rdr.HasRows, "#F13");
+                               Assert.IsFalse (rdr.Read (), "#F14");
+                               Assert.IsFalse (rdr.HasRows, "#F15");
+                       }
+
+                       cmd.CommandText = "SELECT id FROM employee WHERE id = 666; SELECT 3";
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.SchemaOnly)) {
+                               Assert.IsFalse (rdr.HasRows, "#G1");
+                               Assert.IsFalse (rdr.Read (), "#G2");
+                               Assert.IsFalse (rdr.HasRows, "#G3");
+                               Assert.IsTrue (rdr.NextResult (), "#G4");
+                               Assert.IsFalse (rdr.HasRows, "#G5");
+                               Assert.IsFalse (rdr.Read (), "#G6");
+                               Assert.IsFalse (rdr.HasRows, "#G7");
+                               Assert.IsFalse (rdr.NextResult (), "#G8");
+                               Assert.IsFalse (rdr.HasRows, "#G9");
+                               Assert.IsFalse (rdr.Read (), "#G10");
+                               Assert.IsFalse (rdr.HasRows, "#G11");
                        }
                }
 
@@ -1324,7 +1501,7 @@ namespace MonoTests.System.Data.SqlClient
                }
 
                [Test]
-               public void NextResultTest ()
+               public void NextResult ()
                {
                        cmd.CommandText = "Select id from numeric_family where id=1";
                        reader = cmd.ExecuteReader ();
@@ -1334,18 +1511,40 @@ namespace MonoTests.System.Data.SqlClient
                        cmd.CommandText = "select id from numeric_family where id=1;";
                        cmd.CommandText += "select type_bit from numeric_family where id=2;";
                        reader = cmd.ExecuteReader ();
-                       Assert.IsTrue (reader.NextResult (), "#2");
-                       Assert.IsFalse (reader.NextResult (), "#3");
-                       reader.Close ();
-
+                       Assert.IsTrue (reader.NextResult (), "#B1");
+                       Assert.IsTrue (reader.Read (), "#B2");
+                       Assert.IsFalse (reader.NextResult (), "#B3");
                        try {
-                               reader.NextResult ();
-                               Assert.Fail ("#4 Exception shud be thrown : Reader is closed");
-                       }catch (AssertionException e) {
-                               throw e;
-                       }catch (Exception e) {
-                               Assert.AreEqual (typeof(InvalidOperationException), e.GetType (),
-                                       "#5 Incorrect Exception : " + e);
+                               reader.GetValue (0);
+                               Assert.Fail ("#B3");
+                       } catch (InvalidOperationException) {
+                       }
+                       Assert.IsFalse (reader.Read (), "#B4");
+                       try {
+                               reader.GetValue (0);
+                               Assert.Fail ("#B5");
+                       } catch (InvalidOperationException) {
+                       }
+               }
+
+               [Test]
+               public void NextResult_Reader_Close ()
+               {
+                       SqlCommand cmd = conn.CreateCommand ();
+                       cmd.CommandText = "SELECT * FROM employee";
+                       using (SqlDataReader rdr = cmd.ExecuteReader ()) {
+                               rdr.Read ();
+                               rdr.Close ();
+                               try {
+                                       rdr.NextResult ();
+                                       Assert.Fail ("#1");
+                               } catch (InvalidOperationException ex) {
+                                       // Invalid attempt to NextResult when
+                                       // reader is closed
+                                       Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
+                                       Assert.IsNull (ex.InnerException, "#3");
+                                       Assert.IsNotNull (ex.Message, "#4");
+                               }
                        }
                }
 
@@ -2033,104 +2232,351 @@ namespace MonoTests.System.Data.SqlClient
                }
 
                [Test]
-               public void GetFieldTypeTest ()
+               public void GetFieldType_BigInt ()
                {
-                       cmd.CommandText = "Select id , type_tinyint, 10 , null from numeric_family where id=1";
-                       reader = cmd.ExecuteReader ();
+                       cmd.CommandText = "SELECT type_bigint FROM numeric_family WHERE id = 1";
 
-                       Assert.AreEqual ("tinyint", reader.GetDataTypeName(1), "#1");
-                       Assert.AreEqual ("int", reader.GetDataTypeName(2) , "#2");
-                       Assert.AreEqual ("int", reader.GetDataTypeName(3), "#3");
-                       try {
-                               reader.GetDataTypeName (10);
-                               Assert.Fail ("#4 Exception shud be thrown");
-                       }catch (AssertionException e) {
-                               throw e;
-                       }catch (Exception e) {
-                               Assert.AreEqual (typeof(IndexOutOfRangeException), e.GetType(),
-                                       "#5 Incorrect Exception : " + e);
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (long), rdr.GetFieldType (0));
                        }
                }
 
-               // Need to populate the data from a config file
-               // Will be replaced later 
-               void validateData(string sqlQuery, DataTable table)
+               [Test]
+               public void GetFieldType_Binary ()
                {
-                       string fmt = "#TAB[{0}] ROW[{1}] COL[{2}] Data Mismatch";
+                       cmd.CommandText = "SELECT type_binary FROM binary_family WHERE id = 1";
 
-                       int noOfColumns = table.Columns.Count ;
-                       int i=0;
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (byte []), rdr.GetFieldType (0));
+                       }
+               }
 
-                       cmd.CommandText = sqlQuery ;
-                       reader = cmd.ExecuteReader ();
+               [Test]
+               public void GetFieldType_Bit ()
+               {
+                       cmd.CommandText = "SELECT type_bit FROM numeric_family WHERE id = 1";
 
-                       while (reader.Read ()){
-                               for (int j=1; j< noOfColumns ; ++j) {
-                                       Assert.AreEqual (table.Rows[i][j], reader[j],
-                                               String.Format (fmt, table.TableName, i+1, j));
-                               }
-                               
-                               i++;
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (bool), rdr.GetFieldType (0));
                        }
-                       reader.Close ();
                }
 
                [Test]
-               public void NumericDataValidation ()
+               public void GetFieldType_Char ()
                {
-                       validateData ("select * from numeric_family order by id ASC",
-                               numericDataTable);
+                       cmd.CommandText = "SELECT type_char FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (string), rdr.GetFieldType (0));
+                       }
                }
-               
+
                [Test]
-               public void StringDataValidation ()
+               public void GetFieldType_Date ()
                {
-                       validateData ("select * from string_family order by id ASC",
-                               stringDataTable);
+                       // TODO
                }
 
                [Test]
-               public void BinaryDataValidation ()
+               public void GetFieldType_DateTime ()
                {
-                       validateData ("select * from binary_family order by id ASC",
-                               binaryDataTable);
+                       cmd.CommandText = "SELECT type_datetime FROM datetime_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (DateTime), rdr.GetFieldType (0));
+                       }
                }
 
                [Test]
-               public void DatetimeDataValidation ()
+               public void GetFieldType_Decimal ()
                {
-                       validateData ("select * from datetime_family order by id ASC",
-                               datetimeDataTable);
+                       cmd.CommandText = "SELECT type_decimal1 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (decimal), rdr.GetFieldType (0));
+                       }
+
+                       cmd.CommandText = "SELECT type_decimal2 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (decimal), rdr.GetFieldType (0));
+                       }
+
+                       cmd.CommandText = "SELECT type_numeric1 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (decimal), rdr.GetFieldType (0));
+                       }
+
+                       cmd.CommandText = "SELECT type_numeric2 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (decimal), rdr.GetFieldType (0));
+                       }
                }
 
-#if NET_2_0
-               string connectionString = ConnectionManager.Singleton.ConnectionString;
+               [Test]
+               public void GetFieldType_Float ()
+               {
+                       cmd.CommandText = "SELECT type_double FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (double), rdr.GetFieldType (0));
+                       }
+               }
 
-               //FIXME : Add more test cases
                [Test]
-               public void GetProviderSpecificFieldTypeTest ()
+               public void GetFieldType_Image ()
                {
-                       using (SqlConnection conn = new SqlConnection (connectionString)) {
-                               conn.Open ();
-                               SqlCommand cmd = conn.CreateCommand ();
-                               cmd.CommandText = "SELECT * FROM employee";
-                               using (SqlDataReader rdr = cmd.ExecuteReader ()) {
-                                       rdr.Read();
-                                       Assert.AreEqual (6, rdr.FieldCount, "#A1");
-                                       Assert.AreEqual(typeof(SqlInt32), rdr.GetProviderSpecificFieldType (0), "#A2");
-                                       Assert.AreEqual(typeof(SqlString), rdr.GetProviderSpecificFieldType (1), "#A3");
-                                       Assert.AreEqual(typeof(SqlString), rdr.GetProviderSpecificFieldType (2), "#A4");
-                                       Assert.AreEqual(typeof(SqlDateTime), rdr.GetProviderSpecificFieldType (3), "#A5");
-                                       Assert.AreEqual(typeof(SqlDateTime), rdr.GetProviderSpecificFieldType (4), "#A6");
-                                       Assert.AreEqual(typeof(SqlString), rdr.GetProviderSpecificFieldType (5), "#A7");
-                               }
-                               cmd.CommandText = "SELECT * FROM numeric_family";
-                               using (SqlDataReader rdr = cmd.ExecuteReader ()) {
-                                       rdr.Read();
-                                       Assert.AreEqual (15, rdr.FieldCount, "#B1");
-                                       Assert.AreEqual(typeof (SqlInt32), rdr.GetProviderSpecificFieldType(0), "#B2");
-                                       Assert.AreEqual(typeof (SqlBoolean), rdr.GetProviderSpecificFieldType(1), "#B3");
-                                       Assert.AreEqual(typeof (SqlByte), rdr.GetProviderSpecificFieldType(2), "#B4");
+                       cmd.CommandText = "SELECT type_tinyblob FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (byte []), rdr.GetFieldType (0));
+                       }
+               }
+
+               [Test]
+               public void GetFieldType_Int ()
+               {
+                       cmd.CommandText = "SELECT type_int FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (int), rdr.GetFieldType (0));
+                       }
+               }
+
+               [Test]
+               public void GetFieldType_Money ()
+               {
+                       cmd.CommandText = "SELECT type_money FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (decimal), rdr.GetFieldType (0));
+                       }
+               }
+
+               [Test]
+               public void GetFieldType_NChar ()
+               {
+                       cmd.CommandText = "SELECT type_nchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (string), rdr.GetFieldType (0));
+                       }
+               }
+
+               [Test]
+               public void GetFieldType_NText ()
+               {
+                       cmd.CommandText = "SELECT type_ntext FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (string), rdr.GetFieldType (0));
+                       }
+               }
+
+               [Test]
+               public void GetFieldType_NVarChar ()
+               {
+                       cmd.CommandText = "SELECT type_nvarchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (string), rdr.GetFieldType (0));
+                       }
+               }
+
+               [Test]
+               public void GetFieldType_Real ()
+               {
+                       cmd.CommandText = "SELECT type_float FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (float), rdr.GetFieldType (0));
+                       }
+
+               }
+
+               [Test]
+               public void GetFieldType_SmallDateTime ()
+               {
+                       cmd.CommandText = "SELECT type_smalldatetime FROM datetime_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (DateTime), rdr.GetFieldType (0));
+                       }
+               }
+
+               [Test]
+               public void GetFieldType_SmallInt ()
+               {
+                       cmd.CommandText = "SELECT type_smallint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (short), rdr.GetFieldType (0));
+                       }
+               }
+
+               [Test]
+               public void GetFieldType_SmallMoney ()
+               {
+                       cmd.CommandText = "SELECT type_smallmoney FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (decimal), rdr.GetFieldType (0));
+                       }
+               }
+
+               [Test]
+               public void GetFieldType_Text ()
+               {
+                       cmd.CommandText = "SELECT type_text FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (string), rdr.GetFieldType (0));
+                       }
+               }
+
+               [Test]
+               public void GetFieldType_Time ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void GetFieldType_Timestamp ()
+               {
+                       cmd.CommandText = "SELECT type_timestamp FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (byte []), rdr.GetFieldType (0));
+                       }
+               }
+
+               [Test]
+               public void GetFieldType_TinyInt ()
+               {
+                       cmd.CommandText = "SELECT type_tinyint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (byte), rdr.GetFieldType (0));
+                       }
+               }
+
+               [Test]
+               public void GetFieldType_Udt ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void GetFieldType_UniqueIdentifier ()
+               {
+                       cmd.CommandText = "SELECT type_guid FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (Guid), rdr.GetFieldType (0));
+                       }
+               }
+
+               [Test]
+               public void GetFieldType_VarBinary ()
+               {
+                       cmd.CommandText = "SELECT type_varbinary FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (byte []), rdr.GetFieldType (0));
+                       }
+               }
+
+               [Test]
+               public void GetFieldType_VarChar ()
+               {
+                       cmd.CommandText = "SELECT type_varchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               Assert.AreEqual (typeof (string), rdr.GetFieldType (0));
+                       }
+               }
+
+               // Need to populate the data from a config file
+               // Will be replaced later 
+               void validateData(string sqlQuery, DataTable table)
+               {
+                       string fmt = "#TAB[{0}] ROW[{1}] COL[{2}] Data Mismatch";
+
+                       int noOfColumns = table.Columns.Count ;
+                       int i=0;
+
+                       cmd.CommandText = sqlQuery ;
+                       reader = cmd.ExecuteReader ();
+
+                       while (reader.Read ()){
+                               for (int j=1; j< noOfColumns ; ++j) {
+                                       Assert.AreEqual (table.Rows[i][j], reader[j],
+                                               String.Format (fmt, table.TableName, i+1, j));
+                               }
+                               
+                               i++;
+                       }
+                       reader.Close ();
+               }
+
+               [Test]
+               public void NumericDataValidation ()
+               {
+                       validateData ("select * from numeric_family order by id ASC",
+                               numericDataTable);
+               }
+               
+               [Test]
+               public void StringDataValidation ()
+               {
+                       validateData ("select * from string_family order by id ASC",
+                               stringDataTable);
+               }
+
+               [Test]
+               public void BinaryDataValidation ()
+               {
+                       validateData ("select * from binary_family order by id ASC",
+                               binaryDataTable);
+               }
+
+               [Test]
+               public void DatetimeDataValidation ()
+               {
+                       validateData ("select * from datetime_family order by id ASC",
+                               datetimeDataTable);
+               }
+
+#if NET_2_0
+               string connectionString = ConnectionManager.Singleton.ConnectionString;
+
+               //FIXME : Add more test cases
+               [Test]
+               public void GetProviderSpecificFieldTypeTest ()
+               {
+                       using (SqlConnection conn = new SqlConnection (connectionString)) {
+                               conn.Open ();
+                               SqlCommand cmd = conn.CreateCommand ();
+                               cmd.CommandText = "SELECT * FROM employee";
+                               using (SqlDataReader rdr = cmd.ExecuteReader ()) {
+                                       rdr.Read();
+                                       Assert.AreEqual (6, rdr.FieldCount, "#A1");
+                                       Assert.AreEqual(typeof(SqlInt32), rdr.GetProviderSpecificFieldType (0), "#A2");
+                                       Assert.AreEqual(typeof(SqlString), rdr.GetProviderSpecificFieldType (1), "#A3");
+                                       Assert.AreEqual(typeof(SqlString), rdr.GetProviderSpecificFieldType (2), "#A4");
+                                       Assert.AreEqual(typeof(SqlDateTime), rdr.GetProviderSpecificFieldType (3), "#A5");
+                                       Assert.AreEqual(typeof(SqlDateTime), rdr.GetProviderSpecificFieldType (4), "#A6");
+                                       Assert.AreEqual(typeof(SqlString), rdr.GetProviderSpecificFieldType (5), "#A7");
+                               }
+                               cmd.CommandText = "SELECT * FROM numeric_family";
+                               using (SqlDataReader rdr = cmd.ExecuteReader ()) {
+                                       rdr.Read();
+                                       Assert.AreEqual (15, rdr.FieldCount, "#B1");
+                                       Assert.AreEqual(typeof (SqlInt32), rdr.GetProviderSpecificFieldType(0), "#B2");
+                                       Assert.AreEqual(typeof (SqlBoolean), rdr.GetProviderSpecificFieldType(1), "#B3");
+                                       Assert.AreEqual(typeof (SqlByte), rdr.GetProviderSpecificFieldType(2), "#B4");
                                        Assert.AreEqual(typeof (SqlInt16), rdr.GetProviderSpecificFieldType(3), "#B5");
                                        Assert.AreEqual(typeof (SqlInt32), rdr.GetProviderSpecificFieldType(4), "#B6");
                                        Assert.AreEqual(typeof (SqlInt64), rdr.GetProviderSpecificFieldType(5), "#B7");
@@ -2230,6 +2676,24 @@ namespace MonoTests.System.Data.SqlClient
                        }
                }
 
+               [Test]
+               public void GetProviderSpecificValues_Values_Null ()
+               {
+                       cmd.CommandText = "SELECT * FROM employee";
+                       reader = cmd.ExecuteReader ();
+                       reader.Read ();
+
+                       try {
+                               reader.GetProviderSpecificValues (null);
+                               Assert.Fail ("#1");
+                       } catch (ArgumentNullException ex) {
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+                               Assert.IsNull (ex.InnerException, "#3");
+                               Assert.IsNotNull (ex.Message, "#4");
+                               Assert.AreEqual ("values", ex.ParamName, "#5");
+                       }
+               }
+
                [Test]
                public void GetProviderSpecificValuesSmallArrayTest ()
                {
@@ -2371,4 +2835,2152 @@ namespace MonoTests.System.Data.SqlClient
                }
 #endif
        }
+
+       [TestFixture]
+       [Category ("sqlserver")]
+       public class SqlDataReaderSchemaTest
+       {
+               SqlConnection conn;
+               SqlCommand cmd;
+
+               [SetUp]
+               public void SetUp ()
+               {
+                       conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
+                       cmd = conn.CreateCommand ();
+               }
+
+               [TearDown]
+               public void TearDown ()
+               {
+                       if (cmd != null)
+                               cmd.Dispose ();
+                       ConnectionManager.Singleton.CloseConnection ();
+               }
+
+               [Test]
+               public void ColumnSize_BigInt ()
+               {
+                       cmd.CommandText = "SELECT type_bigint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               // we only support TDS 7.0, which returns bigint data values as decimal(19,0)
+                               if (RunningOnMono)
+                                       Assert.AreEqual (17, row ["ColumnSize"], "Value");
+                               else
+                                       Assert.AreEqual (8, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_Binary ()
+               {
+                       cmd.CommandText = "SELECT type_binary FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (8, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_Bit ()
+               {
+                       cmd.CommandText = "SELECT type_bit FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (1, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_Char ()
+               {
+                       cmd.CommandText = "SELECT type_char FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (10, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_Date ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void ColumnSize_DateTime ()
+               {
+                       cmd.CommandText = "SELECT type_datetime FROM datetime_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (8, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_Decimal ()
+               {
+                       cmd.CommandText = "SELECT type_decimal1 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "#A:IsNull");
+                               Assert.AreEqual (17, row ["ColumnSize"], "#A:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_decimal2 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "#B:IsNull");
+                               Assert.AreEqual (17, row ["ColumnSize"], "#B:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_numeric1 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "#C:IsNull");
+                               Assert.AreEqual (17, row ["ColumnSize"], "#C:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_numeric2 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "#D:IsNull");
+                               Assert.AreEqual (17, row ["ColumnSize"], "#D:Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_Float ()
+               {
+                       cmd.CommandText = "SELECT type_double FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (8, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_Image ()
+               {
+                       cmd.CommandText = "SELECT type_tinyblob FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (int.MaxValue, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_Int ()
+               {
+                       cmd.CommandText = "SELECT type_int FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (4, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_Money ()
+               {
+                       cmd.CommandText = "SELECT type_money FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (8, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_NChar ()
+               {
+                       cmd.CommandText = "SELECT type_nchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (10, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_NText ()
+               {
+                       cmd.CommandText = "SELECT type_ntext FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (1073741823, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_NVarChar ()
+               {
+                       cmd.CommandText = "SELECT type_nvarchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (10, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_Real ()
+               {
+                       cmd.CommandText = "SELECT type_float FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (4, row ["ColumnSize"], "Value");
+                       }
+
+               }
+
+               [Test]
+               public void ColumnSize_SmallDateTime ()
+               {
+                       cmd.CommandText = "SELECT type_smalldatetime FROM datetime_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (4, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_SmallInt ()
+               {
+                       cmd.CommandText = "SELECT type_smallint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (2, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_SmallMoney ()
+               {
+                       cmd.CommandText = "SELECT type_smallmoney FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (4, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_Text ()
+               {
+                       cmd.CommandText = "SELECT type_text FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (2147483647, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_Time ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void ColumnSize_Timestamp ()
+               {
+                       cmd.CommandText = "SELECT type_timestamp FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (8, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_TinyInt ()
+               {
+                       cmd.CommandText = "SELECT type_tinyint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (1, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_Udt ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void ColumnSize_UniqueIdentifier ()
+               {
+                       cmd.CommandText = "SELECT type_guid FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (16, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_VarBinary ()
+               {
+                       cmd.CommandText = "SELECT type_varbinary FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (255, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ColumnSize_VarChar ()
+               {
+                       cmd.CommandText = "SELECT type_varchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ColumnSize"), "IsNull");
+                               Assert.AreEqual (10, row ["ColumnSize"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_BigInt ()
+               {
+                       cmd.CommandText = "SELECT type_bigint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (long), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_Binary ()
+               {
+                       cmd.CommandText = "SELECT type_binary FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (byte []), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_Bit ()
+               {
+                       cmd.CommandText = "SELECT type_bit FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (bool), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_Char ()
+               {
+                       cmd.CommandText = "SELECT type_char FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (string), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_Date ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void DataType_DateTime ()
+               {
+                       cmd.CommandText = "SELECT type_datetime FROM datetime_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (DateTime), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_Decimal ()
+               {
+                       cmd.CommandText = "SELECT type_decimal1 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "#A:IsNull");
+                               Assert.AreEqual (typeof (decimal), row ["DataType"], "#A:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_decimal2 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "#B:IsNull");
+                               Assert.AreEqual (typeof (decimal), row ["DataType"], "#B:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_numeric1 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "#C:IsNull");
+                               Assert.AreEqual (typeof (decimal), row ["DataType"], "#C:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_numeric2 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "#D:IsNull");
+                               Assert.AreEqual (typeof (decimal), row ["DataType"], "#D:Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_Float ()
+               {
+                       cmd.CommandText = "SELECT type_double FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (double), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_Image ()
+               {
+                       cmd.CommandText = "SELECT type_tinyblob FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (byte []), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_Int ()
+               {
+                       cmd.CommandText = "SELECT type_int FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (int), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_Money ()
+               {
+                       cmd.CommandText = "SELECT type_money FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (decimal), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_NChar ()
+               {
+                       cmd.CommandText = "SELECT type_nchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (string), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_NText ()
+               {
+                       cmd.CommandText = "SELECT type_ntext FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (string), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_NVarChar ()
+               {
+                       cmd.CommandText = "SELECT type_nvarchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (string), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_Real ()
+               {
+                       cmd.CommandText = "SELECT type_float FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (float), row ["DataType"], "Value");
+                       }
+
+               }
+
+               [Test]
+               public void DataType_SmallDateTime ()
+               {
+                       cmd.CommandText = "SELECT type_smalldatetime FROM datetime_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (DateTime), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_SmallInt ()
+               {
+                       cmd.CommandText = "SELECT type_smallint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (short), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_SmallMoney ()
+               {
+                       cmd.CommandText = "SELECT type_smallmoney FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (decimal), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_Text ()
+               {
+                       cmd.CommandText = "SELECT type_text FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (string), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_Time ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void DataType_Timestamp ()
+               {
+                       cmd.CommandText = "SELECT type_timestamp FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (byte []), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_TinyInt ()
+               {
+                       cmd.CommandText = "SELECT type_tinyint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (byte), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_Udt ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void DataType_UniqueIdentifier ()
+               {
+                       cmd.CommandText = "SELECT type_guid FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (Guid), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_VarBinary ()
+               {
+                       cmd.CommandText = "SELECT type_varbinary FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (byte []), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void DataType_VarChar ()
+               {
+                       cmd.CommandText = "SELECT type_varchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("DataType"), "IsNull");
+                               Assert.AreEqual (typeof (string), row ["DataType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_BigInt ()
+               {
+                       cmd.CommandText = "SELECT type_bigint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_Binary ()
+               {
+                       cmd.CommandText = "SELECT type_binary FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_Bit ()
+               {
+                       cmd.CommandText = "SELECT type_bit FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_Char ()
+               {
+                       cmd.CommandText = "SELECT type_char FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_Date ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void IsLong_DateTime ()
+               {
+                       cmd.CommandText = "SELECT type_datetime FROM datetime_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_Decimal ()
+               {
+                       cmd.CommandText = "SELECT type_decimal1 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "#A:IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "#A:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_decimal2 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "#B:IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "#B:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_numeric1 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "#C:IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "#C:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_numeric2 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "#D:IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "#D:Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_Float ()
+               {
+                       cmd.CommandText = "SELECT type_double FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_Image ()
+               {
+                       cmd.CommandText = "SELECT type_tinyblob FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (true, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_Int ()
+               {
+                       cmd.CommandText = "SELECT type_int FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_Money ()
+               {
+                       cmd.CommandText = "SELECT type_money FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_NChar ()
+               {
+                       cmd.CommandText = "SELECT type_nchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_NText ()
+               {
+                       cmd.CommandText = "SELECT type_ntext FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (true, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_NVarChar ()
+               {
+                       cmd.CommandText = "SELECT type_nvarchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_Real ()
+               {
+                       cmd.CommandText = "SELECT type_float FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+
+               }
+
+               [Test]
+               public void IsLong_SmallDateTime ()
+               {
+                       cmd.CommandText = "SELECT type_smalldatetime FROM datetime_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_SmallInt ()
+               {
+                       cmd.CommandText = "SELECT type_smallint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_SmallMoney ()
+               {
+                       cmd.CommandText = "SELECT type_smallmoney FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_Text ()
+               {
+                       cmd.CommandText = "SELECT type_text FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (true, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_Time ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void IsLong_Timestamp ()
+               {
+                       cmd.CommandText = "SELECT type_timestamp FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_TinyInt ()
+               {
+                       cmd.CommandText = "SELECT type_tinyint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_Udt ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void IsLong_UniqueIdentifier ()
+               {
+                       cmd.CommandText = "SELECT type_guid FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_VarBinary ()
+               {
+                       cmd.CommandText = "SELECT type_varbinary FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void IsLong_VarChar ()
+               {
+                       cmd.CommandText = "SELECT type_varchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("IsLong"), "IsNull");
+                               Assert.AreEqual (false, row ["IsLong"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_BigInt ()
+               {
+                       cmd.CommandText = "SELECT type_bigint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (19, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_Binary ()
+               {
+                       cmd.CommandText = "SELECT type_binary FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_Bit ()
+               {
+                       cmd.CommandText = "SELECT type_bit FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_Char ()
+               {
+                       cmd.CommandText = "SELECT type_char FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_Date ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void NumericPrecision_DateTime ()
+               {
+                       cmd.CommandText = "SELECT type_datetime FROM datetime_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (23, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_Decimal ()
+               {
+                       cmd.CommandText = "SELECT type_decimal1 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "#A:IsNull");
+                               Assert.AreEqual (38, row ["NumericPrecision"], "#A:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_decimal2 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "#B:IsNull");
+                               Assert.AreEqual (10, row ["NumericPrecision"], "#B:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_numeric1 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "#C:IsNull");
+                               Assert.AreEqual (38, row ["NumericPrecision"], "#C:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_numeric2 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "#D:IsNull");
+                               Assert.AreEqual (10, row ["NumericPrecision"], "#D:Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_Float ()
+               {
+                       cmd.CommandText = "SELECT type_double FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (15, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_Image ()
+               {
+                       cmd.CommandText = "SELECT type_tinyblob FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_Int ()
+               {
+                       cmd.CommandText = "SELECT type_int FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (10, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_Money ()
+               {
+                       cmd.CommandText = "SELECT type_money FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (19, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_NChar ()
+               {
+                       cmd.CommandText = "SELECT type_nchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_NText ()
+               {
+                       cmd.CommandText = "SELECT type_ntext FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_NVarChar ()
+               {
+                       cmd.CommandText = "SELECT type_nvarchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_Real ()
+               {
+                       cmd.CommandText = "SELECT type_float FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (7, row ["NumericPrecision"], "Value");
+                       }
+
+               }
+
+               [Test]
+               public void NumericPrecision_SmallDateTime ()
+               {
+                       cmd.CommandText = "SELECT type_smalldatetime FROM datetime_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (16, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_SmallInt ()
+               {
+                       cmd.CommandText = "SELECT type_smallint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (5, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_SmallMoney ()
+               {
+                       cmd.CommandText = "SELECT type_smallmoney FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (10, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_Text ()
+               {
+                       cmd.CommandText = "SELECT type_text FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_Time ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void NumericPrecision_Timestamp ()
+               {
+                       cmd.CommandText = "SELECT type_timestamp FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_TinyInt ()
+               {
+                       cmd.CommandText = "SELECT type_tinyint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (3, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_Udt ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void NumericPrecision_UniqueIdentifier ()
+               {
+                       cmd.CommandText = "SELECT type_guid FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_VarBinary ()
+               {
+                       cmd.CommandText = "SELECT type_varbinary FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_VarChar ()
+               {
+                       cmd.CommandText = "SELECT type_varchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericPrecision"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericPrecision"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericPrecision_Variant ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void NumericPrecision_Xml ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void NumericScale_BigInt ()
+               {
+                       cmd.CommandText = "SELECT type_bigint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               // we only support TDS 7.0, which returns bigint data values as decimal(19,0)
+                               if (RunningOnMono)
+                                       Assert.AreEqual (0, row ["NumericScale"], "Value");
+                               else
+                                       Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_Binary ()
+               {
+                       cmd.CommandText = "SELECT type_binary FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_Bit ()
+               {
+                       cmd.CommandText = "SELECT type_bit FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_Char ()
+               {
+                       cmd.CommandText = "SELECT type_char FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_Date ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void NumericScale_DateTime ()
+               {
+                       cmd.CommandText = "SELECT type_datetime FROM datetime_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (3, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_Decimal ()
+               {
+                       cmd.CommandText = "SELECT type_decimal1 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "#A:IsNull");
+                               Assert.AreEqual (0, row ["NumericScale"], "#A:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_decimal2 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "#B:IsNull");
+                               Assert.AreEqual (3, row ["NumericScale"], "#B:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_numeric1 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "#C:IsNull");
+                               Assert.AreEqual (0, row ["NumericScale"], "#C:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_numeric2 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "#D:IsNull");
+                               Assert.AreEqual (3, row ["NumericScale"], "#D:Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_Float ()
+               {
+                       cmd.CommandText = "SELECT type_double FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_Image ()
+               {
+                       cmd.CommandText = "SELECT type_tinyblob FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_Int ()
+               {
+                       cmd.CommandText = "SELECT type_int FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_Money ()
+               {
+                       cmd.CommandText = "SELECT type_money FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_NChar ()
+               {
+                       cmd.CommandText = "SELECT type_nchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_NText ()
+               {
+                       cmd.CommandText = "SELECT type_ntext FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_NVarChar ()
+               {
+                       cmd.CommandText = "SELECT type_nvarchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_Real ()
+               {
+                       cmd.CommandText = "SELECT type_float FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+
+               }
+
+               [Test]
+               public void NumericScale_SmallDateTime ()
+               {
+                       cmd.CommandText = "SELECT type_smalldatetime FROM datetime_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (0, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_SmallInt ()
+               {
+                       cmd.CommandText = "SELECT type_smallint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_SmallMoney ()
+               {
+                       cmd.CommandText = "SELECT type_smallmoney FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_Text ()
+               {
+                       cmd.CommandText = "SELECT type_text FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_Time ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void NumericScale_Timestamp ()
+               {
+                       cmd.CommandText = "SELECT type_timestamp FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_TinyInt ()
+               {
+                       cmd.CommandText = "SELECT type_tinyint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_Udt ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void NumericScale_UniqueIdentifier ()
+               {
+                       cmd.CommandText = "SELECT type_guid FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_VarBinary ()
+               {
+                       cmd.CommandText = "SELECT type_varbinary FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_VarChar ()
+               {
+                       cmd.CommandText = "SELECT type_varchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("NumericScale"), "IsNull");
+                               Assert.AreEqual (255, row ["NumericScale"], "Value");
+                       }
+               }
+
+               [Test]
+               public void NumericScale_Variant ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void NumericScale_Xml ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void ProviderType_BigInt ()
+               {
+                       cmd.CommandText = "SELECT type_bigint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (0, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_Binary ()
+               {
+                       cmd.CommandText = "SELECT type_binary FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (1, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_Bit ()
+               {
+                       cmd.CommandText = "SELECT type_bit FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (2, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_Char ()
+               {
+                       cmd.CommandText = "SELECT type_char FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (3, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_Date ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void ProviderType_DateTime ()
+               {
+                       cmd.CommandText = "SELECT type_datetime FROM datetime_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (4, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_Decimal ()
+               {
+                       cmd.CommandText = "SELECT type_decimal1 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "#A:IsNull");
+                               Assert.AreEqual (5, row ["ProviderType"], "#A:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_decimal2 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "#B:IsNull");
+                               Assert.AreEqual (5, row ["ProviderType"], "#B:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_numeric1 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "#C:IsNull");
+                               Assert.AreEqual (5, row ["ProviderType"], "#C:Value");
+                       }
+
+                       cmd.CommandText = "SELECT type_numeric2 FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "#D:IsNull");
+                               Assert.AreEqual (5, row ["ProviderType"], "#D:Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_Float ()
+               {
+                       cmd.CommandText = "SELECT type_double FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (6, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_Image ()
+               {
+                       cmd.CommandText = "SELECT type_tinyblob FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (7, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_Int ()
+               {
+                       cmd.CommandText = "SELECT type_int FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (8, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_Money ()
+               {
+                       cmd.CommandText = "SELECT type_money FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (9, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_NChar ()
+               {
+                       cmd.CommandText = "SELECT type_nchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (10, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_NText ()
+               {
+                       cmd.CommandText = "SELECT type_ntext FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (11, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_NVarChar ()
+               {
+                       cmd.CommandText = "SELECT type_nvarchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (12, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_Real ()
+               {
+                       cmd.CommandText = "SELECT type_float FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (13, row ["ProviderType"], "Value");
+                       }
+
+               }
+
+               [Test]
+               public void ProviderType_SmallDateTime ()
+               {
+                       cmd.CommandText = "SELECT type_smalldatetime FROM datetime_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (15, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_SmallInt ()
+               {
+                       cmd.CommandText = "SELECT type_smallint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (16, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_SmallMoney ()
+               {
+                       cmd.CommandText = "SELECT type_smallmoney FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (17, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_Text ()
+               {
+                       cmd.CommandText = "SELECT type_text FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (18, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_Time ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void ProviderType_Timestamp ()
+               {
+                       cmd.CommandText = "SELECT type_timestamp FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               // we currently consider timestamp as binary (due to TDS 7.0?)
+                               if (RunningOnMono)
+                                       Assert.AreEqual (1, row ["ProviderType"], "Value");
+                               else
+                                       Assert.AreEqual (19, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_TinyInt ()
+               {
+                       cmd.CommandText = "SELECT type_tinyint FROM numeric_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (20, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_Udt ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void ProviderType_UniqueIdentifier ()
+               {
+                       cmd.CommandText = "SELECT type_guid FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (14, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_VarBinary ()
+               {
+                       cmd.CommandText = "SELECT type_varbinary FROM binary_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (21, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_VarChar ()
+               {
+                       cmd.CommandText = "SELECT type_varchar FROM string_family WHERE id = 1";
+
+                       using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
+                               DataTable schemaTable = rdr.GetSchemaTable ();
+                               DataRow row = schemaTable.Rows [0];
+                               Assert.IsFalse (row.IsNull ("ProviderType"), "IsNull");
+                               Assert.AreEqual (22, row ["ProviderType"], "Value");
+                       }
+               }
+
+               [Test]
+               public void ProviderType_Variant ()
+               {
+                       // TODO
+               }
+
+               [Test]
+               public void ProviderType_Xml ()
+               {
+                       // TODO
+               }
+
+               static bool RunningOnMono {
+                       get {
+                               return (Type.GetType ("System.MonoType", false) != null);
+                       }
+               }
+       }
 }
index 0ab97b0339ac7aad79d26543ff3bcd94a888ed2d..6940b308176edf3d9b3c5a5e1109c6864bf7029d 100644 (file)
@@ -30,9 +30,7 @@
 
 using System;
 using System.Data;
-using System.Data.Common;
 using System.Data.SqlClient;
-using System.Data.SqlTypes;
 
 using NUnit.Framework;
 
@@ -40,504 +38,33 @@ namespace MonoTests.System.Data.SqlClient
 {
        [TestFixture]
        [Category ("sqlserver")]
-       //FIXME : Add more testcases
        public class SqlParameterTest
        {
-               //testcase for #77410
-               [Test]
-               public void ParameterNullTest ()
-               {
-                       SqlParameter param = new SqlParameter ("param", SqlDbType.Decimal);
-                       Assert.AreEqual (0, param.Scale, "#1");
-                       param.Value = DBNull.Value;
-                       Assert.AreEqual (0, param.Scale, "#2");
-
-                       param = new SqlParameter ("param", SqlDbType.Int);
-                       Assert.AreEqual (0, param.Scale, "#3");
-                       param.Value = DBNull.Value;
-                       Assert.AreEqual (0, param.Scale, "#4");
-               }
-
-               [Test]
-               public void ParameterType ()
-               {
-                       // If Type is not set, then type is inferred from the value
-                       // assigned. The Type should be inferred everytime Value is assigned
-                       // If value is null or DBNull, then the current Type should be reset to NVarChar.
-                       SqlParameter param = new SqlParameter ();
-                       Assert.AreEqual (DbType.String, param.DbType, "#A1");
-                       Assert.AreEqual (SqlDbType.NVarChar, param.SqlDbType, "#A2");
-                       param.Value = DBNull.Value;
-                       Assert.AreEqual (DbType.String, param.DbType, "#A3");
-                       Assert.AreEqual (SqlDbType.NVarChar, param.SqlDbType, "#A4");
-                       param.Value = 1;
-                       Assert.AreEqual (DbType.Int32, param.DbType, "#A5");
-                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, "#A6");
-                       param.Value = DBNull.Value;
-#if NET_2_0
-                       Assert.AreEqual (DbType.String, param.DbType, "#A7");
-                       Assert.AreEqual (SqlDbType.NVarChar, param.SqlDbType, "#A8");
-#else
-                       Assert.AreEqual (DbType.Int32, param.DbType, "#A7");
-                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, "#A8");
-#endif
-                       param.Value = null;
-#if NET_2_0
-                       Assert.AreEqual (DbType.String, param.DbType, "#A9");
-                       Assert.AreEqual (SqlDbType.NVarChar, param.SqlDbType, "#A10");
-#else
-                       Assert.AreEqual (DbType.Int32, param.DbType, "#A9");
-                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, "#A10");
-#endif
-                       param.Value = DateTime.Now;
-                       Assert.AreEqual (DbType.DateTime, param.DbType, "#A11");
-                       Assert.AreEqual (SqlDbType.DateTime, param.SqlDbType, "#A12");
-                       param.Value = null;
-#if NET_2_0
-                       Assert.AreEqual (DbType.String, param.DbType, "#A13");
-                       Assert.AreEqual (SqlDbType.NVarChar, param.SqlDbType, "#A14");
-#else
-                       Assert.AreEqual (DbType.DateTime, param.DbType, "#A13");
-                       Assert.AreEqual (SqlDbType.DateTime, param.SqlDbType, "#A14");
-#endif
-
-                       // If DbType is set, then the SqlDbType should not be
-                       // inferred from the value assigned.
-                       SqlParameter param1 = new SqlParameter ();
-                       param1.DbType = DbType.String;
-                       Assert.AreEqual (SqlDbType.NVarChar, param1.SqlDbType, "#B1");
-                       param1.Value = 1;
-                       Assert.AreEqual (SqlDbType.NVarChar, param1.SqlDbType, "#B2");
-
-                       // If SqlDbType is set, then the DbType should not be
-                       // inferred from the value assigned.
-                       SqlParameter param2 = new SqlParameter ();
-                       param2.SqlDbType = SqlDbType.NVarChar;
-                       Assert.AreEqual (SqlDbType.NVarChar, param2.SqlDbType, "#C1");
-                       param2.Value = 1;
-                       Assert.AreEqual (SqlDbType.NVarChar, param2.SqlDbType, "#C2");
-               }
-
-               [Test]
-               public void InferType_Boolean ()
-               {
-                       Boolean value;
-                       SqlParameter param;
-                       
-                       value = false;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.Bit, param.SqlDbType, "#A1");
-                       Assert.AreEqual (DbType.Boolean, param.DbType, "#A2");
-
-                       value = true;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.Bit, param.SqlDbType, "#B1");
-                       Assert.AreEqual (DbType.Boolean, param.DbType, "#B2");
-               }
-
-               [Test]
-               public void InferType_Byte ()
-               {
-                       Byte value = 0x0a;
-
-                       SqlParameter param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.TinyInt, param.SqlDbType, "#1");
-                       Assert.AreEqual (DbType.Byte, param.DbType, "#2");
-               }
-
-               [Test]
-               public void InferType_ByteArray ()
-               {
-                       Byte [] value = new Byte [] { 0x0a, 0x0d };
-
-                       SqlParameter param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.VarBinary, param.SqlDbType, "#1");
-                       Assert.AreEqual (DbType.Binary, param.DbType, "#2");
-               }
-
-               [Test]
-               public void InferType_Char ()
-               {
-                       Char value = Char.MaxValue;
-
-                       SqlParameter param = new SqlParameter ();
-#if NET_2_0
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.NVarChar, param.SqlDbType, "#1");
-                       Assert.AreEqual (DbType.String, param.DbType, "#2");
-#else
-                       try {
-                               param.Value = value;
-                               Assert.Fail ("#1");
-                       } catch (ArgumentException ex) {
-                               // The parameter data type of Char is invalid
-                               Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
-                               Assert.IsNull (ex.InnerException, "#3");
-                               Assert.IsNotNull (ex.Message, "#4");
-                               Assert.IsNull (ex.ParamName, "#5");
-                       }
-#endif
-               }
-
-               [Test]
-               public void InferType_CharArray ()
-               {
-                       Char [] value = new Char [] { 'A', 'X' };
-
-                       SqlParameter param = new SqlParameter ();
-#if NET_2_0
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.NVarChar, param.SqlDbType, "#1");
-                       Assert.AreEqual (DbType.String, param.DbType, "#2");
-#else
-                       try {
-                               param.Value = value;
-                               Assert.Fail ("#1");
-                       } catch (FormatException) {
-                               // appears to be bug in .NET 1.1 while constructing
-                               // exception message
-                       } catch (ArgumentException ex) {
-                               // The parameter data type of Char[] is invalid
-                               Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
-                               Assert.IsNull (ex.InnerException, "#3");
-                               Assert.IsNotNull (ex.Message, "#4");
-                               Assert.IsNull (ex.ParamName, "#5");
-                       }
-#endif
-               }
-
-               [Test]
-               public void InferType_DateTime ()
-               {
-                       DateTime value;
-                       SqlParameter param;
-
-                       value = DateTime.Now;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.DateTime, param.SqlDbType, "#A1");
-                       Assert.AreEqual (DbType.DateTime, param.DbType, "#A2");
-
-                       value = DateTime.Now;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.DateTime, param.SqlDbType, "#B1");
-                       Assert.AreEqual (DbType.DateTime, param.DbType, "#B2");
-
-                       value = new DateTime (1973, 8, 13);
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.DateTime, param.SqlDbType, "#C1");
-                       Assert.AreEqual (DbType.DateTime, param.DbType, "#C2");
-               }
-
-               [Test]
-               public void InferType_Decimal ()
-               {
-                       Decimal value;
-                       SqlParameter param;
-                       
-                       value = Decimal.MaxValue;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.Decimal, param.SqlDbType, "#A1");
-                       Assert.AreEqual (DbType.Decimal, param.DbType, "#A2");
-
-                       value = Decimal.MinValue;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.Decimal, param.SqlDbType, "#B1");
-                       Assert.AreEqual (DbType.Decimal, param.DbType, "#B2");
-
-                       value = 214748.364m;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.Decimal, param.SqlDbType, "#C1");
-                       Assert.AreEqual (DbType.Decimal, param.DbType, "#C2");
-               }
-
-               [Test]
-               public void InferType_Double ()
-               {
-                       Double value;
-                       SqlParameter param;
-                       
-                       value = Double.MaxValue;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.Float, param.SqlDbType, "#A1");
-                       Assert.AreEqual (DbType.Double, param.DbType, "#A2");
-
-                       value = Double.MinValue;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.Float, param.SqlDbType, "#B1");
-                       Assert.AreEqual (DbType.Double, param.DbType, "#B2");
-
-                       value = 0d;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.Float, param.SqlDbType, "#C1");
-                       Assert.AreEqual (DbType.Double, param.DbType, "#C2");
-               }
-
-               [Test]
-               public void InferType_Enum ()
-               {
-                       SqlParameter param;
-
-                       param = new SqlParameter ();
-                       param.Value = ByteEnum.A;
-                       Assert.AreEqual (SqlDbType.TinyInt, param.SqlDbType, "#A1");
-                       Assert.AreEqual (DbType.Byte, param.DbType, "#A2");
-
-                       param = new SqlParameter ();
-                       param.Value = Int64Enum.A;
-                       Assert.AreEqual (SqlDbType.BigInt, param.SqlDbType, "#B1");
-                       Assert.AreEqual (DbType.Int64, param.DbType, "#B2");
-               }
-
-               [Test]
-               public void InferType_Guid ()
-               {
-                       Guid value = Guid.NewGuid ();
-
-                       SqlParameter param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.UniqueIdentifier, param.SqlDbType, "#1");
-                       Assert.AreEqual (DbType.Guid, param.DbType, "#2");
-               }
-
-               [Test]
-               public void InferType_Int16 ()
-               {
-                       Int16 value;
-                       SqlParameter param;
-                       
-                       value = Int16.MaxValue;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.SmallInt, param.SqlDbType, "#A1");
-                       Assert.AreEqual (DbType.Int16, param.DbType, "#A2");
-
-                       value = Int16.MinValue;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.SmallInt, param.SqlDbType, "#B1");
-                       Assert.AreEqual (DbType.Int16, param.DbType, "#B2");
-
-                       value = (Int16) 0;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.SmallInt, param.SqlDbType, "#C1");
-                       Assert.AreEqual (DbType.Int16, param.DbType, "#C2");
-               }
-
-               [Test]
-               public void InferType_Int32 ()
-               {
-                       Int32 value;
-                       SqlParameter param;
-                       
-                       value = Int32.MaxValue;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, "#A1");
-                       Assert.AreEqual (DbType.Int32, param.DbType, "#A2");
-
-                       value = Int32.MinValue;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, "#B1");
-                       Assert.AreEqual (DbType.Int32, param.DbType, "#B2");
-
-                       value = 0;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.Int, param.SqlDbType, "#C1");
-                       Assert.AreEqual (DbType.Int32, param.DbType, "#C2");
-               }
-
-               [Test]
-               public void InferType_Int64 ()
-               {
-                       Int64 value;
-                       SqlParameter param;
-                       
-                       value = Int64.MaxValue;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.BigInt, param.SqlDbType, "#A1");
-                       Assert.AreEqual (DbType.Int64, param.DbType, "#A2");
-
-                       value = Int64.MinValue;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.BigInt, param.SqlDbType, "#B1");
-                       Assert.AreEqual (DbType.Int64, param.DbType, "#B2");
-
-                       value = 0L;
-                       param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.BigInt, param.SqlDbType, "#C1");
-                       Assert.AreEqual (DbType.Int64, param.DbType, "#C2");
-               }
-
-               [Test]
-               public void InferType_Invalid ()
-               {
-                       object [] notsupported = new object [] {
-                               UInt16.MaxValue,
-                               UInt32.MaxValue,
-                               UInt64.MaxValue,
-                               SByte.MaxValue,
-                               new SqlParameter ()
-                       };
-
-                       SqlParameter param = new SqlParameter ();
-
-                       for (int i = 0; i < notsupported.Length; i++) {
-#if NET_2_0
-                               param.Value = notsupported [i];
-                               try {
-                                       SqlDbType type = param.SqlDbType;
-                                       Assert.Fail ("#A1:" + i + " (" + type + ")");
-                               } catch (ArgumentException ex) {
-                                       // The parameter data type of ... is invalid
-                                       Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
-                                       Assert.IsNull (ex.InnerException, "#A3");
-                                       Assert.IsNotNull (ex.Message, "#A4");
-                                       Assert.IsNull (ex.ParamName, "#A5");
-                               }
+               SqlConnection conn;
+               SqlCommand cmd;
+               SqlDataReader rdr;
 
-                               try {
-                                       DbType type = param.DbType;
-                                       Assert.Fail ("#B1:" + i + " (" + type + ")");
-                               } catch (ArgumentException ex) {
-                                       // The parameter data type of ... is invalid
-                                       Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
-                                       Assert.IsNull (ex.InnerException, "#B3");
-                                       Assert.IsNotNull (ex.Message, "#B4");
-                                       Assert.IsNull (ex.ParamName, "#B5");
-                               }
-#else
-                               try {
-                                       param.Value = notsupported [i];
-                                       Assert.Fail ("#A1:" + i);
-                               } catch (FormatException) {
-                                       // appears to be bug in .NET 1.1 while
-                                       // constructing exception message
-                               } catch (ArgumentException ex) {
-                                       // The parameter data type of ... is invalid
-                                       Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
-                                       Assert.IsNull (ex.InnerException, "#A3");
-                                       Assert.IsNotNull (ex.Message, "#A4");
-                                       Assert.IsNull (ex.ParamName, "#A5");
-                               }
-#endif
-                       }
-               }
-
-               [Test]
-               public void InferType_Object ()
-               {
-                       Object value = new Object ();
-
-                       SqlParameter param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.Variant, param.SqlDbType, "#1");
-                       Assert.AreEqual (DbType.Object, param.DbType, "#2");
-               }
-
-               [Test]
-               public void InferType_Single ()
-               {
-                       Single value = Single.MaxValue;
-
-                       SqlParameter param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.Real, param.SqlDbType, "#1");
-                       Assert.AreEqual (DbType.Single, param.DbType, "#2");
-               }
-
-               [Test]
-               public void InferType_String ()
+               [SetUp]
+               public void SetUp ()
                {
-                       String value = "some text";
-
-                       SqlParameter param = new SqlParameter ();
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.NVarChar, param.SqlDbType, "#1");
-                       Assert.AreEqual (DbType.String, param.DbType, "#2");
+                       conn = (SqlConnection) ConnectionManager.Singleton.Connection;
+                       ConnectionManager.Singleton.OpenConnection ();
                }
 
-               [Test]
-               public void InferType_TimeSpan ()
+               [TearDown]
+               public void TearDown ()
                {
-                       TimeSpan value = new TimeSpan (4, 6, 23);
-
-                       SqlParameter param = new SqlParameter ();
-#if NET_2_0
-                       param.Value = value;
-                       Assert.AreEqual (SqlDbType.Time, param.SqlDbType, "#1");
-                       Assert.AreEqual (DbType.Time, param.DbType, "#2");
-#else
-                       try {
-                               param.Value = value;
-                               Assert.Fail ("#1");
-                       } catch (FormatException) {
-                               // appears to be bug in .NET 1.1 while constructing
-                               // exception message
-                       } catch (ArgumentException ex) {
-                               Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
-                               Assert.IsNull (ex.InnerException, "#3");
-                               Assert.IsNotNull (ex.Message, "#4");
-                               Assert.IsNull (ex.ParamName, "#5");
-                       }
-#endif
+                       if (cmd != null)
+                               cmd.Dispose ();
+                       if (rdr != null)
+                               rdr.Close ();
+                       ConnectionManager.Singleton.CloseConnection ();
                }
 
-               [Test]
-               public void SqlDbTypeTest ()
-               {
-                       SqlParameter p1 = new SqlParameter ();
-                       Assert.AreEqual (null, p1.Value, "#1 Value of the parameter must be null by default");
-                       Assert.AreEqual (SqlDbType.NVarChar, p1.SqlDbType, "#2 parameters without any value or null value must have SqlDbtype as NVarChar");
-                       Assert.AreEqual (DbType.String, p1.DbType, "#3 parameters without any value must have DbType as NVarChar");
-                       
-                       SqlParameter p2 = new SqlParameter ("#4 p2Name", (Object)null);
-                       Assert.AreEqual (null, p2.Value, "#5 Value of the parameter must be null by default");
-                       Assert.AreEqual (SqlDbType.NVarChar, p2.SqlDbType, "#6 parameters without any value or null value must have SqlDbtype as NVarChar");
-                       Assert.AreEqual (DbType.String, p2.DbType, "#7parameters without any value or null value must have DbType as String");
-                       
-                       p2.Value = Convert.ToInt32(42);
-                       Assert.AreEqual (42, p2.Value, "#8 Value of the parameter must be 42");
-                       Assert.AreEqual (SqlDbType.Int, p2.SqlDbType, "#9 parameter must have SqlDbtype as Int");
-                       Assert.AreEqual (DbType.Int32, p2.DbType, "#10 parameter must have Dbtype as Int32");
-
-                       p2.Value = DBNull.Value;
-                       Assert.AreEqual (DBNull.Value, p2.Value, "#11 Value of the parameter must be DBNull.Value");
-#if NET_2_0
-                       Assert.AreEqual (SqlDbType.NVarChar, p2.SqlDbType, "#12 parameters without any value or null value must have SqlDbtype as NVarChar");
-                       Assert.AreEqual (DbType.String, p2.DbType, "#13 parameters without any value or null value must have DbType as String");
-#else
-                       Assert.AreEqual (SqlDbType.Int, p2.SqlDbType, "#12 parameter must have SqlDbtype as Int");
-                       Assert.AreEqual (DbType.Int32, p2.DbType, "#13 parameter must have Dbtype as Int32");
-#endif
-               }
-
-               //testcase for #82170
-               [Test]
+               [Test] // bug #324840
                public void ParameterSizeTest ()
                {
-                       SqlConnection conn = new SqlConnection (ConnectionManager.Singleton.ConnectionString);
-                       conn.Open ();
                        string longstring = new String('x', 20480);
-                       SqlCommand cmd;
                        SqlParameter prm;
                        cmd = new SqlCommand ("create table #text1 (ID int not null, Val1 ntext)", conn);
                        cmd.ExecuteNonQuery ();
@@ -589,283 +116,108 @@ namespace MonoTests.System.Data.SqlClient
                        cmd.ExecuteNonQuery ();
                        conn.Close ();
                }
-#if NET_2_0
-               [Test]
-               public void ResetSqlDbTypeTest ()
-               {
-                       //Parameter with an assigned value but no SqlDbType specified
-                       SqlParameter p1 = new SqlParameter ("foo", 42);
-                       Assert.AreEqual (42, p1.Value, "#1");
-                       Assert.AreEqual (DbType.Int32, p1.DbType, "#2");
-                       Assert.AreEqual (SqlDbType.Int, p1.SqlDbType, "#3");
-
-                       p1.ResetSqlDbType ();
-                       Assert.AreEqual (DbType.Int32, p1.DbType, "#4 The parameter with value 42 must have DbType as Int32");
-                       Assert.AreEqual (SqlDbType.Int, p1.SqlDbType, "#5 The parameter with value 42 must have SqlDbType as Int");
-
-                       p1.SqlDbType = SqlDbType.DateTime; //assigning a SqlDbType
-                       Assert.AreEqual (DbType.DateTime, p1.DbType, "#6");
-                       Assert.AreEqual (SqlDbType.DateTime, p1.SqlDbType, "#7");
-                       p1.ResetSqlDbType (); //Resetting SqlDbType
-                       Assert.AreEqual (DbType.Int32, p1.DbType, "#8 Resetting SqlDbType must infer the type from the value");
-                       Assert.AreEqual (SqlDbType.Int, p1.SqlDbType, "#9 Resetting SqlDbType must infer the type from the value");
-
-                       //Parameter with an assigned SqlDbType but no specified value
-                       SqlParameter p2 = new SqlParameter ("foo", SqlDbType.Int);
-                       Assert.AreEqual (null, p2.Value, "#10");
-                       Assert.AreEqual (DbType.Int32, p2.DbType, "#11");
-                       Assert.AreEqual (SqlDbType.Int, p2.SqlDbType, "#12");
-
-                       //Although a SqlDbType is specified, calling ResetSqlDbType resets 
-                       //the SqlDbType and DbType properties to default values
-                       p2.ResetSqlDbType ();
-                       Assert.AreEqual (DbType.String, p2.DbType, "#13 Resetting SqlDbType must infer the type from the value");
-                       Assert.AreEqual (SqlDbType.NVarChar, p2.SqlDbType, "#14 Resetting SqlDbType must infer the type from the value");
-
-                       p2.SqlDbType = SqlDbType.DateTime; //assigning a SqlDbType
-                       Assert.AreEqual (DbType.DateTime, p2.DbType, "#15");
-                       Assert.AreEqual (SqlDbType.DateTime, p2.SqlDbType, "#16");
-                       p2.ResetSqlDbType (); //Resetting SqlDbType
-                       Assert.AreEqual (DbType.String, p2.DbType, "#17 Resetting SqlDbType must infer the type from the value");
-                       Assert.AreEqual (SqlDbType.NVarChar, p2.SqlDbType, "#18 Resetting SqlDbType must infer the type from the value");
-               }
-
-               [Test]
-               public void ResetDbTypeTest ()
-               {
-                       //Parameter with an assigned value but no DbType specified
-                       SqlParameter p1 = new SqlParameter ("foo", 42);
-                       Assert.AreEqual (42, p1.Value, "#1");
-                       Assert.AreEqual (DbType.Int32, p1.DbType, "#2");
-                       Assert.AreEqual (SqlDbType.Int, p1.SqlDbType, "#3");
-
-                       p1.ResetDbType ();
-                       Assert.AreEqual (DbType.Int32, p1.DbType, "#4 The parameter with value 42 must have DbType as Int32");
-                       Assert.AreEqual (SqlDbType.Int, p1.SqlDbType, "#5 The parameter with value 42 must have SqlDbType as Int32");
-
-                       p1.DbType = DbType.DateTime; //assigning a DbType
-                       Assert.AreEqual (DbType.DateTime, p1.DbType, "#6");
-                       Assert.AreEqual (SqlDbType.DateTime, p1.SqlDbType, "#7");
-                       p1.ResetDbType (); //Resetting DbType
-                       Assert.AreEqual (DbType.Int32, p1.DbType, "#8 Resetting DbType must infer the type from the value");
-                       Assert.AreEqual (SqlDbType.Int, p1.SqlDbType, "#9 Resetting DbType must infer the type from the value");
-
-                       //Parameter with an assigned SqlDbType but no specified value
-                       SqlParameter p2 = new SqlParameter ("foo", SqlDbType.Int);
-                       Assert.AreEqual (null, p2.Value, "#10");
-                       Assert.AreEqual (DbType.Int32, p2.DbType, "#11");
-                       Assert.AreEqual (SqlDbType.Int, p2.SqlDbType, "#12");
-
-                       //Although a SqlDbType is specified, calling ResetDbType resets 
-                       //the SqlDbType and DbType properties to default values
-                       p2.ResetDbType (); 
-                       Assert.AreEqual (DbType.String, p2.DbType, "#13 Resetting DbType must infer the type from the value");
-                       Assert.AreEqual (SqlDbType.NVarChar, p2.SqlDbType, "#14 Resetting DbType must infer the type from the value");
-
-                       p2.DbType = DbType.DateTime; //assigning a SqlDbType
-                       Assert.AreEqual (DbType.DateTime, p2.DbType, "#15");
-                       Assert.AreEqual (SqlDbType.DateTime, p2.SqlDbType, "#16");
-                       p2.ResetDbType (); //Resetting DbType
-                       Assert.AreEqual (DbType.String, p2.DbType, "#17 Resetting DbType must infer the type from the value");
-                       Assert.AreEqual (SqlDbType.NVarChar, p2.SqlDbType, "#18 Resetting DbType must infer the type from the value");
-               }
-
-               [Test]
-               public void XmlSchemaTest ()
-               {
-                       SqlParameter p1 = new SqlParameter ();
-                       
-                       //Testing default values
-                       Assert.AreEqual (String.Empty, p1.XmlSchemaCollectionDatabase,
-                                        "#1 Default value for XmlSchemaCollectionDatabase is an empty string");
-                       Assert.AreEqual (String.Empty, p1.XmlSchemaCollectionName,
-                                        "#2 Default value for XmlSchemaCollectionName is an empty string");
-                       Assert.AreEqual (String.Empty, p1.XmlSchemaCollectionOwningSchema,
-                                        "#3 Default value for XmlSchemaCollectionOwningSchema is an empty string");
 
-                       //Changing one property should not affect the remaining two properties
-                       p1.XmlSchemaCollectionDatabase = "database";
-                       Assert.AreEqual ("database", p1.XmlSchemaCollectionDatabase,
-                                        "#4 Default value for XmlSchemaCollectionDatabase is an empty string");
-                       Assert.AreEqual (String.Empty, p1.XmlSchemaCollectionName,
-                                        "#5 Default value for XmlSchemaCollectionName is an empty string");
-                       Assert.AreEqual (String.Empty, p1.XmlSchemaCollectionOwningSchema,
-                                        "#6 Default value for XmlSchemaCollectionOwningSchema is an empty string");
-
-                       p1.XmlSchemaCollectionName = "name";
-                       Assert.AreEqual ("database", p1.XmlSchemaCollectionDatabase,
-                                        "#7 Default value for XmlSchemaCollectionDatabase is an empty string");
-                       Assert.AreEqual ("name", p1.XmlSchemaCollectionName,
-                                        "#8 Default value for XmlSchemaCollectionName is an empty string");
-                       Assert.AreEqual (String.Empty, p1.XmlSchemaCollectionOwningSchema,
-                                        "#9 Default value for XmlSchemaCollectionOwningSchema is an empty string");
-
-                       p1.XmlSchemaCollectionOwningSchema = "schema";
-                       Assert.AreEqual ("database", p1.XmlSchemaCollectionDatabase,
-                                        "#10 Default value for XmlSchemaCollectionDatabase is an empty string");
-                       Assert.AreEqual ("name", p1.XmlSchemaCollectionName,
-                                        "#11 Default value for XmlSchemaCollectionName is an empty string");
-                       Assert.AreEqual ("schema", p1.XmlSchemaCollectionOwningSchema,
-                                        "#12 Default value for XmlSchemaCollectionOwningSchema is an empty string");
-
-                       //assigning null value stores default empty string
-                       p1.XmlSchemaCollectionDatabase = null;
-                       Assert.AreEqual (String.Empty, p1.XmlSchemaCollectionDatabase,
-                                        "#13 Default value for XmlSchemaCollectionDatabase is an empty string");
-                       Assert.AreEqual ("name", p1.XmlSchemaCollectionName,
-                                        "#14 Default value for XmlSchemaCollectionName is an empty string");
-                       Assert.AreEqual ("schema", p1.XmlSchemaCollectionOwningSchema,
-                                        "#15 Default value for XmlSchemaCollectionOwningSchema is an empty string");
-
-                       p1.XmlSchemaCollectionName = "";
-                       Assert.AreEqual (String.Empty, p1.XmlSchemaCollectionDatabase,
-                                        "#16 Default value for XmlSchemaCollectionDatabase is an empty string");
-                       Assert.AreEqual ("", p1.XmlSchemaCollectionName,
-                                        "#17 Default value for XmlSchemaCollectionName is an empty string");
-                       Assert.AreEqual ("schema", p1.XmlSchemaCollectionOwningSchema,
-                                        "#18 Default value for XmlSchemaCollectionOwningSchema is an empty string");
-
-                       //values are not trimmed
-                       p1.XmlSchemaCollectionOwningSchema = "  a  ";
-                       Assert.AreEqual (String.Empty, p1.XmlSchemaCollectionDatabase,
-                                        "#19 Default value for XmlSchemaCollectionDatabase is an empty string");
-                       Assert.AreEqual ("", p1.XmlSchemaCollectionName,
-                                        "#20 Default value for XmlSchemaCollectionName is an empty string");
-                       Assert.AreEqual ("  a  ", p1.XmlSchemaCollectionOwningSchema,
-                                        "#21 Default value for XmlSchemaCollectionOwningSchema is an empty string");
-               }
-
-               [Test]
-               public void SourceColumnNullMappingTest ()
-               {
-                       SqlParameter p1 = new SqlParameter ();
-                       Assert.AreEqual (false, p1.SourceColumnNullMapping, "#1 SourceColumnNullMapping should be false by default");
-                       p1.SourceColumnNullMapping = true;
-                       Assert.AreEqual (true, p1.SourceColumnNullMapping, "#2 SourceColumnNullMapping should be false by default");
-               }
-
-               [Test]
-               public void ctor7Test ()
-               {
-                       SqlParameter p1 = new SqlParameter ("p1Name", SqlDbType.VarChar, 20,
-                                                           ParameterDirection.InputOutput, 0, 0,
-                                                           "srcCol", DataRowVersion.Original, false,
-                                                           "foo", "database", "schema", "name");
-                       Assert.AreEqual (DbType.AnsiString, p1.DbType, "#");
-                       Assert.AreEqual (ParameterDirection.InputOutput, p1.Direction, "#");
-                       Assert.AreEqual (false, p1.IsNullable, "#");
-                       //Assert.AreEqual (999, p1.LocaleId, "#");
-                       Assert.AreEqual ("p1Name", p1.ParameterName, "#");
-                       Assert.AreEqual (0, p1.Precision, "#");
-                       Assert.AreEqual (0, p1.Scale, "#");
-                       Assert.AreEqual (20, p1.Size, "#");
-                       Assert.AreEqual ("srcCol", p1.SourceColumn, "#");
-                       Assert.AreEqual (false, p1.SourceColumnNullMapping, "#");
-                       Assert.AreEqual (DataRowVersion.Original, p1.SourceVersion, "#");
-                       Assert.AreEqual (SqlDbType.VarChar, p1.SqlDbType, "#");
-                       //Assert.AreEqual (3210, p1.SqlValue, "#");
-                       Assert.AreEqual ("foo", p1.Value, "#");
-                       Assert.AreEqual ("database", p1.XmlSchemaCollectionDatabase, "#");
-                       Assert.AreEqual ("name", p1.XmlSchemaCollectionName, "#");
-                       Assert.AreEqual ("schema", p1.XmlSchemaCollectionOwningSchema, "#");
-               }
-
-               [Test]
-               public void CompareInfoTest ()
-               {
-                       SqlParameter parameter = new SqlParameter ();
-                       Assert.AreEqual (SqlCompareOptions.None, parameter.CompareInfo, "#1 Default value should be System.Data.SqlTypes.SqlCompareOptions.None");
-
-                       parameter.CompareInfo = SqlCompareOptions.IgnoreNonSpace;
-                       Assert.AreEqual (SqlCompareOptions.IgnoreNonSpace, parameter.CompareInfo, "#2 It should return CompareOptions.IgnoreSpace after setting this value for the property");
-               }
-       
-               [Test]
-               public void LocaleIdTest ()
-               {
-                       SqlParameter parameter = new SqlParameter ();
-                       Assert.AreEqual (0, parameter.LocaleId, "#1 Default value for the property should be 0");
-
-                       parameter.LocaleId = 15;
-                       Assert.AreEqual(15, parameter.LocaleId, "#2");
-               }
-
-               [Test]
-               public void SqlValue ()
-               {
-                       SqlParameter parameter = new SqlParameter ();
-                       Assert.AreEqual (null, parameter.SqlValue, "#1 Default value for the property should be Null");
-
-                       parameter.SqlValue = SqlDbType.Char.ToString ();
-                       Assert.AreEqual ("Char", parameter.SqlValue, "#1 The value for the property should be Char after setting SqlDbType to Char");
-               }
-#endif
-
-               [Test]
-               // Test for Bug#382635
+               [Test] // bug #382635
                public void ParameterSize_compatibility_Test ()
                {
-                       SqlConnection conn = new SqlConnection (ConnectionManager.Singleton.ConnectionString);
-                       conn.Open ();
-                       string longstring = new String('x', 256);
+                       string longstring = "abcdefghijklmnopqrstuvwxyz";
 
-                       SqlCommand cmd, cmd1;
-                       try {
-                               cmd = new SqlCommand ("create table #bug382635 (description varchar(50))", conn);
-                               cmd.ExecuteNonQuery ();
-                       } catch (SqlException e) {
-                               Assert.Fail ("#PSCT1 - Exception thrown while creating the temp table");
-                               throw e;
-                       }
+                       cmd = new SqlCommand ("create table #bug382635 (description varchar(20))", conn);
+                       cmd.ExecuteNonQuery ();
 
                        cmd.CommandText = 
-                                       "CREATE PROCEDURE #sp_bug382635 (@Desc varchar(50)) "
+                                       "CREATE PROCEDURE #sp_bug382635 (@Desc varchar(20)) "
                                        + "AS " + Environment.NewLine 
                                        + "BEGIN" + Environment.NewLine 
                                        + "UPDATE #bug382635 SET description = @Desc" + Environment.NewLine
                                        + "END";
                        cmd.CommandType = CommandType.Text;
-                       try {
-                               cmd.ExecuteNonQuery ();
-                       } catch (SqlException e) {
-                               Assert.Fail ("#PSCT1 - Exception thrown while creating the temp procedure");
-                               throw e;
-                       }
+                       cmd.ExecuteNonQuery ();
 
                        cmd.CommandText = "INSERT INTO #bug382635 " +
-                                         "(description) VALUES ('This is a test to verify Bug 382635')";
+                                         "(description) VALUES ('Verifies bug #382635')";
                        cmd.ExecuteNonQuery ();
 
                        cmd.CommandText = "#sp_bug382635";
                        cmd.CommandType = CommandType.StoredProcedure;
 
-                       SqlParameter p1 = new SqlParameter ("@Desc", SqlDbType.NVarChar, 50);
+                       SqlParameter p1 = new SqlParameter ("@Desc", SqlDbType.NVarChar, 15);
                        p1.Value = longstring;
+                       Assert.AreEqual (longstring, p1.Value);
                        cmd.Parameters.Add (p1);
                        cmd.ExecuteNonQuery ();
 
                        // Test for truncation
-                       cmd1 = new SqlCommand ("SELECT DATALENGTH(description) from #bug382635", conn);
-                       Assert.AreEqual (50, cmd1.ExecuteScalar (), "#PSCT1");
+                       SqlCommand selectCmd = new SqlCommand ("SELECT DATALENGTH(description), description from #bug382635", conn);
+
+                       rdr = selectCmd.ExecuteReader ();
+                       Assert.IsTrue (rdr.Read (), "#A1");
+                       Assert.AreEqual (15, rdr.GetValue (0), "#A2");
+                       Assert.AreEqual (longstring.Substring (0, 15), rdr.GetValue (1), "#A3");
+                       Assert.AreEqual (longstring, p1.Value, "#A4");
+                       rdr.Close ();
+
+                       // Test to ensure truncation is not done in the Value getter/setter
+                       p1.Size = 12;
+                       p1.Value = longstring.Substring (0, 22);
+                       p1.Size = 14;
+                       cmd.ExecuteNonQuery ();
+
+                       rdr = selectCmd.ExecuteReader ();
+                       Assert.IsTrue (rdr.Read (), "#B1");
+                       Assert.AreEqual (14, rdr.GetValue (0), "#B2");
+                       Assert.AreEqual (longstring.Substring (0, 14), rdr.GetValue (1), "#B3");
+                       Assert.AreEqual (longstring.Substring (0, 22), p1.Value, "#B4");
+                       rdr.Close ();
 
-                       // Test for regular scenarios
-                       p1.Value = longstring.Substring (0, 20);
+                       // Size exceeds size of value
+                       p1.Size = 40;
                        cmd.ExecuteNonQuery ();
-                       Assert.AreEqual (20, cmd1.ExecuteScalar (), "#PSCT1");
-                       cmd.Dispose ();
-                       cmd1.Dispose ();
-               }
 
-               private enum ByteEnum : byte
-               {
-                       A = 0x0a,
-                       B = 0x0d
+                       rdr = selectCmd.ExecuteReader ();
+                       Assert.IsTrue (rdr.Read (), "#C1");
+                       Assert.AreEqual (20, rdr.GetValue (0), "#C2");
+                       Assert.AreEqual (longstring.Substring (0, 20), rdr.GetValue (1), "#C3");
+                       rdr.Close ();
                }
 
-               private enum Int64Enum : long
+               [Test]
+               public void ConversionToSqlTypeInvalid ()
                {
-                       A = long.MinValue,
-                       B = long.MaxValue
+                       string insert_data = "insert into datetime_family (id, type_datetime) values (6000, @type_datetime)";
+                       string delete_data = "delete from datetime_family where id = 6000";
+
+                       object [] values = new object [] {
+                               5,
+                               true,
+                               40L,
+                               "invalid date",
+                               };
+
+                       try {
+                               for (int i = 0; i < values.Length; i++) {
+                                       object value = values [i];
+
+                                       cmd = conn.CreateCommand ();
+                                       cmd.CommandText = insert_data;
+                                       SqlParameter param = cmd.Parameters.Add ("@type_datetime", SqlDbType.DateTime);
+                                       param.Value = value;
+                                       cmd.Prepare ();
+
+                                       try {
+                                               cmd.ExecuteNonQuery ();
+                                               Assert.Fail ("#1:" + i);
+                                       } catch (InvalidCastException) {
+                                               if (value is string)
+                                                       Assert.Fail ("#2");
+                                       } catch (FormatException) {
+                                               if (!(value is string))
+                                                       Assert.Fail ("#3");
+                                       }
+                               }
+                       } finally {
+                               DBHelper.ExecuteNonQuery (conn, delete_data);
+                       }
                }
        }
 }