Exemplo n.º 1
0
 public int deleteQuestion(int id)
 {
     OdbcCommand command = new OdbcCommand("delete from question where id=?", connection);
     command.Parameters.Add(new OdbcParameter("id", OdbcType.Int)).Value = id;
     command.Prepare();
     return command.ExecuteNonQuery();
 }
Exemplo n.º 2
0
 public int deleteQuestionByExamId(int examinationId)
 {
     OdbcCommand command = new OdbcCommand("delete from question where examinationId=?", connection);
     command.Parameters.Add(new OdbcParameter("examinationId", OdbcType.Int)).Value = examinationId;
     command.Prepare();
     return command.ExecuteNonQuery();
 }
Exemplo n.º 3
0
        public List<ResultEntity> getResultByExaminationId(int examinationId)
        {
            List<ResultEntity> resultList = new List<ResultEntity>();
            OdbcCommand command = new OdbcCommand("select * from result where examinationId=?", connection);
            command.Parameters.Add(new OdbcParameter("examinationId", OdbcType.Int)).Value = examinationId;
            command.Prepare();
            OdbcDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                ResultEntity result = new ResultEntity();

                result.id = reader.GetInt32(0);
                result.studentId = reader.GetInt32(1);
                result.examinationId = reader.GetInt32(2);
                result.sQuestion = reader.GetString(3);
                result.mQuestion = reader.GetString(4);
                result.tQuestion = reader.GetString(5);
                result.sScore = reader.GetDouble(6);
                result.mScore = reader.GetDouble(7);
                result.tScore = reader.GetDouble(8);
                resultList.Add(result);
            }
            return resultList;

        }
Exemplo n.º 4
0
 public int addQuesiton(int type,string answer,string options,string picture,string description,int examinationId)
 {
     OdbcCommand command = new OdbcCommand("insert into question(type,answer,options,picture,discription,examinationId) values (?,?,?,?,?,?)",connection);
     command.Parameters.Add(new OdbcParameter("type", OdbcType.Int)).Value = type;
     command.Parameters.Add(new OdbcParameter("anwser", OdbcType.VarChar)).Value = answer;
     command.Parameters.Add(new OdbcParameter("options", OdbcType.VarChar)).Value = options;
     command.Parameters.Add(new OdbcParameter("picture", OdbcType.VarChar)).Value = picture;
     command.Parameters.Add(new OdbcParameter("description", OdbcType.VarChar)).Value = description;
     command.Parameters.Add(new OdbcParameter("examinationId", OdbcType.Int)).Value = examinationId;
     command.Prepare();
     return command.ExecuteNonQuery();
 }
Exemplo n.º 5
0
 public ResultEntity getResultById(int id)
 {
     ResultEntity result = null;
     OdbcCommand command = new OdbcCommand("select * from result where id=?", connection);
     command.Parameters.Add(new OdbcParameter("id", OdbcType.Int)).Value = id;
     command.Prepare();
     OdbcDataReader reader = command.ExecuteReader();
     if (reader.Read())
     {
         result = new ResultEntity();
         result.id = reader.GetInt32(0);
         result.studentId = reader.GetInt32(1);
         result.examinationId = reader.GetInt32(2);
         result.sQuestion = reader.GetString(3);
         result.mQuestion = reader.GetString(4);
         result.tQuestion = reader.GetString(5);
         result.sScore = reader.GetDouble(6);
         result.mScore = reader.GetDouble(7);
         result.tScore = reader.GetDouble(8);
     }
     return result;
 }
Exemplo n.º 6
0
 public List<ExamEntity> getAllExam()
 {
     List<ExamEntity> list = new List<ExamEntity>();
     OdbcCommand command = new OdbcCommand("select * from examination order by id desc", connection);
     command.Prepare();
     OdbcDataReader reader =  command.ExecuteReader();
     while (reader.Read())
     {
         ExamEntity exam = new ExamEntity();
         exam.id = reader.GetInt32(0);
         exam.time = reader.GetInt32(1);
         exam.sNumber = reader.GetInt32(2);
         exam.mNumber = reader.GetInt32(3);
         exam.tNumber = reader.GetInt32(4);
         exam.sScore = reader.GetFloat(5);
         exam.mScore = reader.GetFloat(6);
         exam.tScore = reader.GetFloat(7);
         exam.ready = reader.GetInt32(8);
         exam.name = reader.GetString(9);
         list.Add(exam);
     }
     return list;
 }
Exemplo n.º 7
0
 public int modifyStatus(int id, int status)
 {
     OdbcCommand command = new OdbcCommand("update examination set ready=? where id=?", connection);
     command.Parameters.Add(new OdbcParameter("name", OdbcType.Int)).Value = status;
     command.Parameters.Add(new OdbcParameter("id", OdbcType.Int)).Value = id;
     command.Prepare();
     return command.ExecuteNonQuery();
 }
Exemplo n.º 8
0
        public int setExamName(int id, string name, int sNum, int mNum, int tNum, double sScore, double mScore, double tScore, int Time)
        {
            OdbcCommand command = new OdbcCommand("update examination set name=?,sNumber=?,mNumber=?,tNumber=?,sScore=?,mScore=?,tScore=?,time=? where id=?", connection);

            command.Parameters.Add(new OdbcParameter("name", OdbcType.VarChar)).Value = name;
            command.Parameters.Add(new OdbcParameter("sNumber", OdbcType.Int)).Value = sNum;
            command.Parameters.Add(new OdbcParameter("mNumber", OdbcType.Int)).Value = mNum;
            command.Parameters.Add(new OdbcParameter("tNumber", OdbcType.Int)).Value = tNum;
            command.Parameters.Add(new OdbcParameter("sScore", OdbcType.Double)).Value = mScore;
            command.Parameters.Add(new OdbcParameter("mScore", OdbcType.Double)).Value = sScore;
            command.Parameters.Add(new OdbcParameter("tScore", OdbcType.Double)).Value = tScore;
            command.Parameters.Add(new OdbcParameter("time", OdbcType.Int)).Value = Time;
            command.Parameters.Add(new OdbcParameter("id", OdbcType.Int)).Value = id;
            command.Prepare();
            return command.ExecuteNonQuery();
        }
Exemplo n.º 9
0
        public int setExamName(int id,string name)
        {
            OdbcCommand command = new OdbcCommand("update examination set name=? where id=?",connection);
            command.Parameters.Add(new OdbcParameter("name", OdbcType.VarChar)).Value = name;
            command.Parameters.Add(new OdbcParameter("id", OdbcType.Int)).Value = id;
            command.Prepare();
            return command.ExecuteNonQuery();

        }
Exemplo n.º 10
0
        /// <summary>
        ///    插入考试
        /// </summary>
        /// <param name="time">考试时间</param>
        /// <param name="sNum">单选数量</param>
        /// <param name="mNum">多选数量</param>
        /// <param name="tfNum">判断数量</param>
        /// <param name="sScore">单选分数</param>
        /// <param name="mScore">多选分数</param>
        /// <param name="tfScore">判断分数</param>
        /// <param name="ready">是否可见,0为不可见,1为课件,默认为0</param>
        /// <param name="name">课程名字</param>
        /// <returns>插入成功返回插入的id,-1插入失败,-2获取last_insert_id失败</returns>
        public int addExam(int time, int sNum, int mNum, int tfNum, double sScore, double mScore, double tfScore, int ready = 0,string name="")//ready 初始默认为0
        {
            
            OdbcCommand command = new OdbcCommand("insert into examination(time,sNumber,mNumber,tNumber,sScore,mScore,tScore,ready,name) values (?,?,?,?,?,?,?,?,?)", connection);
            command.Parameters.Add(new OdbcParameter("time", OdbcType.Int)).Value = time;
            command.Parameters.Add(new OdbcParameter("sNumber", OdbcType.Int)).Value = sNum;
            command.Parameters.Add(new OdbcParameter("mNumber", OdbcType.Int)).Value = mNum;
            command.Parameters.Add(new OdbcParameter("tNumber", OdbcType.Int)).Value = tfNum;
            command.Parameters.Add(new OdbcParameter("sScore", OdbcType.Double)).Value = sScore;
            command.Parameters.Add(new OdbcParameter("mScore", OdbcType.Double)).Value = mScore;
            command.Parameters.Add(new OdbcParameter("tScore", OdbcType.Double)).Value = tfScore;
            command.Parameters.Add(new OdbcParameter("ready", OdbcType.Int)).Value = ready;
            command.Parameters.Add(new OdbcParameter("name", OdbcType.VarChar)).Value = name;
            command.Prepare();

            if (command.ExecuteNonQuery() > 0)
            {
                command = new OdbcCommand("select last_insert_id()",connection);
                command.Prepare();
                var reader = command.ExecuteReader();
                if (reader.Read())
                {
                    return reader.GetInt32(0);
                }
                return -2;
            }
            return -1;
        }
Exemplo n.º 11
0
		public void PrepareAndExecuteTest ()
		{
			OdbcDataReader reader = null;

			try {
				string tableName = DBHelper.GetRandomName ("PAE", 3);
				try {
					// setup table
					string query = "DROP TABLE " + tableName ;
					DBHelper.ExecuteNonQuery (conn, query);
					query = String.Format ("CREATE TABLE {0} ( id INT, small_id SMALLINT )",
							       tableName);
					DBHelper.ExecuteNonQuery (conn, query);

					query = String.Format ("INSERT INTO {0} values (?, ?)", tableName);
					cmd = conn.CreateCommand ();
					cmd.CommandText = query;
					cmd.Prepare ();

					OdbcParameter param1 = cmd.Parameters.Add ("?", OdbcType.Int);
					OdbcParameter param2 = cmd.Parameters.Add ("?", OdbcType.SmallInt);
					param1.Value = 1;
					param2.Value = 5;
					cmd.ExecuteNonQuery ();

					param1.Value = 2;
					param2.Value = 6;
					cmd.ExecuteNonQuery ();

					cmd.CommandText = "select id, small_id from " + tableName + " order by id asc";
					reader = cmd.ExecuteReader ();

#if NET_2_0
					Assert.IsTrue (reader.Read (), "#A1");
					Assert.AreEqual (1, reader.GetValue (0), "#A2");
					Assert.AreEqual (5, reader.GetValue (1), "#A3");
					Assert.IsTrue (reader.Read (), "#A4");
					Assert.AreEqual (2, reader.GetValue (0), "#A5");
					Assert.AreEqual (6, reader.GetValue (1), "#A6");
					Assert.IsFalse (reader.Read (), "#A7");
#else
					// in .NET 1.x, changing the CommandText
					// does not reset prepared state
					Assert.IsFalse (reader.Read (), "#A1");
#endif
					reader.Close ();
					cmd.Dispose ();

					cmd = conn.CreateCommand ();
					cmd.CommandText = "select id, small_id from " + tableName + " order by id asc";

					reader = cmd.ExecuteReader ();
					Assert.IsTrue (reader.Read (), "#B1");
					Assert.AreEqual (1, reader.GetValue (0), "#B2");
					Assert.AreEqual (5, reader.GetValue (1), "#B3");
					Assert.IsTrue (reader.Read (), "#B4");
					Assert.AreEqual (2, reader.GetValue (0), "#B5");
					Assert.AreEqual (6, reader.GetValue (1), "#B6");
#if NET_2_0
					Assert.IsFalse (reader.Read (), "#B7");
#else
					Assert.IsTrue (reader.Read (), "#B7");
					Assert.AreEqual (2, reader.GetValue (0), "#B8");
					Assert.AreEqual (6, reader.GetValue (1), "#B9");
#endif
				} finally {
					DBHelper.ExecuteNonQuery (conn, "DROP TABLE " + tableName);
				}
			} finally {
				if (reader != null)
					reader.Close ();
			}
		}
Exemplo n.º 12
0
		public void ExecuteNonQueryTest ()
		{
			int ret;

			cmd.CommandType = CommandType.Text;
			cmd.CommandText = "select count(*) from employee where id <= ?;";
			cmd.Parameters.Add ("@un", OdbcType.Int).Value = 3;
			ret = cmd.ExecuteNonQuery ();
#if NET_2_0
			switch (ConnectionManager.Singleton.Engine.Type) {
			case EngineType.SQLServer:
				Assert.AreEqual (-1, ret, "#1");
				break;
			case EngineType.MySQL:
				Assert.AreEqual (1, ret, "#1");
				break;
			default:
				Assert.Fail ("Engine type not supported.");
				break;
			}
#else
			Assert.AreEqual (-1, ret,  "#1");
#endif

			cmd = conn.CreateCommand ();
			cmd.CommandType = CommandType.Text;
			cmd.CommandText = "select * from employee where id <= ?;";
			cmd.Parameters.Add ("@un", OdbcType.Int).Value = 3;
			ret = cmd.ExecuteNonQuery ();
#if NET_2_0
			switch (ConnectionManager.Singleton.Engine.Type) {
			case EngineType.SQLServer:
				Assert.AreEqual (-1, ret, "#2");
				break;
			case EngineType.MySQL:
				Assert.AreEqual (3, ret, "#2");
				break;
			default:
				Assert.Fail ("Engine type not supported.");
				break;
			}
#else
			Assert.AreEqual (-1, ret, "#2");
#endif

			cmd = conn.CreateCommand ();
			cmd.CommandType = CommandType.Text;
			cmd.CommandText = "select * from employee where id <= 3;";
			ret = cmd.ExecuteNonQuery ();
#if NET_2_0
			switch (ConnectionManager.Singleton.Engine.Type) {
			case EngineType.SQLServer:
				Assert.AreEqual (-1, ret, "#3");
				break;
			case EngineType.MySQL:
				Assert.AreEqual (3, ret, "#3");
				break;
			default:
				Assert.Fail ("Engine type not supported.");
				break;
			}
#else
			Assert.AreEqual (-1, ret, "#3");
#endif

			try {
				// insert
				cmd = conn.CreateCommand ();
				cmd.CommandType = CommandType.Text;
				cmd.CommandText = "insert into employee (id, fname, dob, doj) values " +
					" (6001, 'tttt', '1999-01-22', '2005-02-11');";
				ret = cmd.ExecuteNonQuery ();
				Assert.AreEqual (1, ret, "#4");

				cmd = conn.CreateCommand ();
				cmd.CommandType = CommandType.Text;
				cmd.CommandText = "insert into employee (id, fname, dob, doj) values " +
					" (?, 'tttt', '1999-01-22', '2005-02-11');";
				cmd.Parameters.Add (new OdbcParameter ("id", OdbcType.Int));
				cmd.Parameters [0].Value = 6002;
				cmd.Prepare ();
				ret = cmd.ExecuteNonQuery ();
				Assert.AreEqual (1, ret, "#5");
			} finally {
				// delete
				cmd = (OdbcCommand) conn.CreateCommand ();
				cmd.CommandType = CommandType.Text;
				cmd.CommandText = "delete from employee where id > 6000";
				ret = cmd.ExecuteNonQuery ();
				Assert.AreEqual (2, ret, "#6");
			}
		}
Exemplo n.º 13
0
        private void labOrderBut_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(patCombo.SelectedIndex.ToString());

                    OdbcConnection conn = new OdbcConnection();
                    OdbcCommand cmd = new OdbcCommand();
                    OdbcDataReader readr;

                    OdbcConnection connIns = new OdbcConnection();
                    OdbcCommand cmdIns = new OdbcCommand();

                    OdbcParameter p1;
                    OdbcParameter p2;
                    //OdbcParameter p3;

               int lastVisit=0;
               int lastLab = 0;

            if (patCombo.SelectedIndex < 0 || testCombo.SelectedIndex < 0 || labDatePick.Text == " " || statCombo.SelectedIndex < 0)
            {
                MessageBox.Show("Please select Patient,Test and Date");
            }
            else
            {
                        try
                        {

                           conn.ConnectionString = "dsn=Physician;" + "Pwd=shnake24;";
                           conn.Open();
                           cmd.Connection = conn;

                            string lastVisitSql = "select max(visit#) from visit ";

                            cmd.CommandText = lastVisitSql;

                           readr = cmd.ExecuteReader();

                           while (readr.Read())
                           {
                               lastVisit = readr.GetInt16(0);
                           }

                           conn.Close();
                           readr.Close();

                    }
                    catch(Exception ex)
                    {
                        MessageBox.Show("error" + ex.Message);
                    }

                        try
                        {
                            conn.ConnectionString = "dsn=Physician;" + "Pwd=shnake24;";
                            conn.Open();
                            cmd.Connection = conn;

                            string lastLabSql = "select max(visit#) from lab_order";

                            cmd.CommandText = lastLabSql;

                            readr = cmd.ExecuteReader();

                            while (readr.Read())
                            {
                                lastLab = readr.GetInt16(0);
                            }

                            conn.Close();
                            readr.Close();

                            /// insert query

                            connIns.ConnectionString = "dsn=Physician;" + "Pwd=shnake24;";
                            connIns.Open();
                            cmdIns.Connection = connIns;

                            cmdIns.CommandText = "INSERT INTO PHYS_ADMIN.VISIT (VISIT#,PERSON_ID,ADMIT_DATE) VALUES (:VISIT#,:PERSON_ID,:ADMIT_DATE)";
                            cmdIns.Prepare();

                            lastVisit = lastVisit + 1;
                            cmdIns.Parameters.AddWithValue("VISIT#",lastVisit);
                            cmdIns.Parameters.AddWithValue("PERSON_ID",patCombo.SelectedIndex+1);
                            cmdIns.Parameters.AddWithValue("ADMIT_DATE",labDatePick.Value);

                            cmdIns.ExecuteNonQuery();
                            cmdIns.Parameters.Clear();

                            cmdIns.CommandText = "Insert into PHYS_ADMIN.LAB_ORDER(LAB_ORDER#,VISIT#,COLLECT_DATE,STATUS,NOTES,TEST_NAME) values (:LAB_ORDER#,:VISIT#,to_date(':COLLECT_DATE', 'mm/dd/yyyy hh24:mi:ss'),:STATUS,:NOTES,:TEST_NAME)";

                            cmdIns.Prepare();

                            cmdIns.Parameters.AddWithValue("lab_order", lastLab);
                            cmdIns.Parameters.AddWithValue("VISIT#", lastVisit);
                            cmdIns.Parameters.AddWithValue("PERSON_ID", patCombo.SelectedIndex + 1);
                            cmdIns.Parameters.AddWithValue("COLLECT_DATE", labDatePick.Value);
                            cmdIns.Parameters.AddWithValue("STATUS",statCombo.Text );
                            cmdIns.Parameters.AddWithValue("NOTES", testNotArea.Text);
                            cmdIns.Parameters.AddWithValue("TEST_NAME",testCombo.Text);

                            cmdIns.ExecuteNonQuery();

                            MessageBox.Show("Order Created");

                            cmdIns.Parameters.Clear();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("error" + ex.Message);
                        }

            }
        }
Exemplo n.º 14
0
		public void GetSchemaTable ()
		{
			IDataReader reader = null;
			DataTable schema;
			DataRow pkRow;

			try {
				cmd.CommandText = "select id, fname, id + 20 as plustwenty from employee";
				reader = cmd.ExecuteReader (CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo);
				schema = reader.GetSchemaTable ();
				reader.Close ();

				AssertSchemaTableStructure (schema, "#A:");
				Assert.AreEqual (3, schema.Rows.Count, "#A:RowCount");
				pkRow = schema.Select ("ColumnName = 'id'") [0];
				Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#A:ColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["ColumnName"], "#A:ColumnName_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#A:ColumnOrdinal_IsNull");
				Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#A:ColumnOrdinal_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#A:ColumnSize_IsNull");
				Assert.AreEqual (4, pkRow ["ColumnSize"], "#A:ColumnSize_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#A:NumericPrecision_IsNull");
				Assert.AreEqual (10, pkRow ["NumericPrecision"], "#A:NumericPrecision_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#A:NumericScale_IsNull");
				Assert.AreEqual (0, pkRow ["NumericScale"], "#A:NumericScale_Value");
				Assert.IsFalse (pkRow.IsNull ("DataType"), "#A:DataType_IsNull");
				Assert.AreEqual (typeof (int), pkRow ["DataType"], "#A:DataType_Value");
				Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#A:ProviderType_IsNull");
				Assert.AreEqual (10, pkRow ["ProviderType"], "#A:ProviderType_Value");
				Assert.IsFalse (pkRow.IsNull ("IsLong"), "#A:IsLong_IsNull");
				Assert.AreEqual (false, pkRow ["IsLong"], "#A:IsLong_Value");
				Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#A:AllowDBNull_IsNull");
				Assert.AreEqual (false, pkRow ["AllowDBNull"], "#A:AllowDBNull_Value");
				Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#A:IsReadOnly_IsNull");
				Assert.AreEqual (false, pkRow ["IsReadOnly"], "#A:IsReadOnly_Value");
				Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#A:IsRowVersion_IsNull");
				Assert.AreEqual (false, pkRow ["IsRowVersion"], "#A:IsRowVersion_Value");
				Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#A:IsUnique_IsNull");
				Assert.AreEqual (true, pkRow ["IsUnique"], "#A:IsUnique_Value");
				Assert.IsFalse (pkRow.IsNull ("IsKey"), "#A:IsKey_IsNull");
				Assert.AreEqual (true, pkRow ["IsKey"], "#A:IsKey_Value");
				Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#A:IsAutoIncrement_IsNull");
				Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#A:IsAutoIncrement_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#A:BaseSchemaName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#A:BaseSchemaName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseCatalogName"), "#A:BaseCatalogName_IsNull");
				Assert.AreEqual ("monotest", pkRow ["BaseCatalogName"], "#A:BaseCatalogName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseTableName"), "#A:BaseTableName_IsNull");
				Assert.AreEqual ("employee", pkRow ["BaseTableName"], "#A:BaseTableName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseColumnName"), "#A:BaseColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["BaseColumnName"], "#A:BaseColumnName_Value");

				reader = cmd.ExecuteReader (CommandBehavior.SchemaOnly);
				schema = reader.GetSchemaTable ();
				reader.Close ();

				AssertSchemaTableStructure (schema, "#B:");
				Assert.AreEqual (3, schema.Rows.Count, "#B:RowCount");
				pkRow = schema.Select ("ColumnName = 'id'") [0];
				Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#B:ColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["ColumnName"], "#B:ColumnName_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#B:ColumnOrdinal_IsNull");
				Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#B:ColumnOrdinal_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#B:ColumnSize_IsNull");
				Assert.AreEqual (4, pkRow ["ColumnSize"], "#B:ColumnSize_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#B:NumericPrecision_IsNull");
				Assert.AreEqual (10, pkRow ["NumericPrecision"], "#B:NumericPrecision_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#B:NumericScale_IsNull");
				Assert.AreEqual (0, pkRow ["NumericScale"], "#B:NumericScale_Value");
				Assert.IsFalse (pkRow.IsNull ("DataType"), "#B:DataType_IsNull");
				Assert.AreEqual (typeof (int), pkRow ["DataType"], "#B:DataType_Value");
				Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#B:ProviderType_IsNull");
				Assert.AreEqual (10, pkRow ["ProviderType"], "#B:ProviderType_Value");
				Assert.IsFalse (pkRow.IsNull ("IsLong"), "#B:IsLong_IsNull");
				Assert.AreEqual (false, pkRow ["IsLong"], "#B:IsLong_Value");
				Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#B:AllowDBNull_IsNull");
				Assert.AreEqual (false, pkRow ["AllowDBNull"], "#B:AllowDBNull_Value");
				Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#B:IsReadOnly_IsNull");
				Assert.AreEqual (false, pkRow ["IsReadOnly"], "#B:IsReadOnly_Value");
				Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#B:IsRowVersion_IsNull");
				Assert.AreEqual (false, pkRow ["IsRowVersion"], "#B:IsRowVersion_Value");
				Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#B:IsUnique_IsNull");
				Assert.AreEqual (false, pkRow ["IsUnique"], "#B:IsUnique_Value");
				Assert.IsFalse (pkRow.IsNull ("IsKey"), "#B:IsKey_IsNull");
				Assert.AreEqual (false, pkRow ["IsKey"], "#B:IsKey_Value");
				Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#B:IsAutoIncrement_IsNull");
				Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#B:IsAutoIncrement_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#B:BaseSchemaName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#B:BaseSchemaName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseCatalogName"), "#B:BaseCatalogName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseCatalogName"], "#B:BaseCatalogName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseTableName"), "#B:BaseTableName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseTableName"], "#B:BaseTableName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseColumnName"), "#B:BaseColumnName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseColumnName"], "#B:BaseColumnName_Value");

				reader = cmd.ExecuteReader (CommandBehavior.KeyInfo);
				schema = reader.GetSchemaTable ();
				reader.Close ();

				AssertSchemaTableStructure (schema, "#C:");
				Assert.AreEqual (3, schema.Rows.Count, "#C:RowCount");
				pkRow = schema.Select ("ColumnName = 'id'") [0];
				Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#C:ColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["ColumnName"], "#C:ColumnName_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#C:ColumnOrdinal_IsNull");
				Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#C:ColumnOrdinal_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#C:ColumnSize_IsNull");
				Assert.AreEqual (4, pkRow ["ColumnSize"], "#C:ColumnSize_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#C:NumericPrecision_IsNull");
				Assert.AreEqual (10, pkRow ["NumericPrecision"], "#C:NumericPrecision_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#C:NumericScale_IsNull");
				Assert.AreEqual (0, pkRow ["NumericScale"], "#C:NumericScale_Value");
				Assert.IsFalse (pkRow.IsNull ("DataType"), "#C:DataType_IsNull");
				Assert.AreEqual (typeof (int), pkRow ["DataType"], "#C:DataType_Value");
				Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#C:ProviderType_IsNull");
				Assert.AreEqual (10, pkRow ["ProviderType"], "#C:ProviderType_Value");
				Assert.IsFalse (pkRow.IsNull ("IsLong"), "#C:IsLong_IsNull");
				Assert.AreEqual (false, pkRow ["IsLong"], "#C:IsLong_Value");
				Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#C:AllowDBNull_IsNull");
				Assert.AreEqual (false, pkRow ["AllowDBNull"], "#C:AllowDBNull_Value");
				Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#C:IsReadOnly_IsNull");
				Assert.AreEqual (false, pkRow ["IsReadOnly"], "#C:IsReadOnly_Value");
				Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#C:IsRowVersion_IsNull");
				Assert.AreEqual (false, pkRow ["IsRowVersion"], "#C:IsRowVersion_Value");
				Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#C:IsUnique_IsNull");
				Assert.AreEqual (true, pkRow ["IsUnique"], "#C:IsUnique_Value");
				Assert.IsFalse (pkRow.IsNull ("IsKey"), "#C:IsKey_IsNull");
				Assert.AreEqual (true, pkRow ["IsKey"], "#C:IsKey_Value");
				Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#C:IsAutoIncrement_IsNull");
				Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#C:IsAutoIncrement_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#C:BaseSchemaName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#C:BaseSchemaName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseCatalogName"), "#C:BaseCatalogName_IsNull");
				Assert.AreEqual ("monotest", pkRow ["BaseCatalogName"], "#C:BaseCatalogName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseTableName"), "#C:BaseTableName_IsNull");
				Assert.AreEqual ("employee", pkRow ["BaseTableName"], "#C:BaseTableName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseColumnName"), "#C:BaseColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["BaseColumnName"], "#C:BaseColumnName_Value");

				reader = cmd.ExecuteReader ();
				schema = reader.GetSchemaTable ();
				reader.Close ();

				AssertSchemaTableStructure (schema, "#D:");
				Assert.AreEqual (3, schema.Rows.Count, "#D:RowCount");
				pkRow = schema.Select ("ColumnName = 'id'") [0];
				Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#D:ColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["ColumnName"], "#D:ColumnName_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#D:ColumnOrdinal_IsNull");
				Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#D:ColumnOrdinal_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#D:ColumnSize_IsNull");
				Assert.AreEqual (4, pkRow ["ColumnSize"], "#D:ColumnSize_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#D:NumericPrecision_IsNull");
				Assert.AreEqual (10, pkRow ["NumericPrecision"], "#D:NumericPrecision_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#D:NumericScale_IsNull");
				Assert.AreEqual (0, pkRow ["NumericScale"], "#D:NumericScale_Value");
				Assert.IsFalse (pkRow.IsNull ("DataType"), "#D:DataType_IsNull");
				Assert.AreEqual (typeof (int), pkRow ["DataType"], "#D:DataType_Value");
				Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#D:ProviderType_IsNull");
				Assert.AreEqual (10, pkRow ["ProviderType"], "#D:ProviderType_Value");
				Assert.IsFalse (pkRow.IsNull ("IsLong"), "#D:IsLong_IsNull");
				Assert.AreEqual (false, pkRow ["IsLong"], "#D:IsLong_Value");
				Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#D:AllowDBNull_IsNull");
				Assert.AreEqual (false, pkRow ["AllowDBNull"], "#D:AllowDBNull_Value");
				Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#D:IsReadOnly_IsNull");
				Assert.AreEqual (false, pkRow ["IsReadOnly"], "#D:IsReadOnly_Value");
				Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#D:IsRowVersion_IsNull");
				Assert.AreEqual (false, pkRow ["IsRowVersion"], "#D:IsRowVersion_Value");
				Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#D:IsUnique_IsNull");
				Assert.AreEqual (false, pkRow ["IsUnique"], "#D:IsUnique_Value");
				Assert.IsFalse (pkRow.IsNull ("IsKey"), "#D:IsKey_IsNull");
				Assert.AreEqual (false, pkRow ["IsKey"], "#D:IsKey_Value");
				Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#D:IsAutoIncrement_IsNull");
				Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#D:IsAutoIncrement_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#D:BaseSchemaName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#D:BaseSchemaName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseCatalogName"), "#D:BaseCatalogName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseCatalogName"], "#D:BaseCatalogName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseTableName"), "#D:BaseTableName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseTableName"], "#D:BaseTableName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseColumnName"), "#D:BaseColumnName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseColumnName"], "#D:BaseColumnName_Value");

				cmd = conn.CreateCommand ();
				cmd.CommandText = "select id, fname, id + 20 as plustwenty from employee";
				cmd.Prepare ();
				reader = cmd.ExecuteReader (CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo);
				schema = reader.GetSchemaTable ();
				reader.Close ();

				AssertSchemaTableStructure (schema, "#E:");
				Assert.AreEqual (3, schema.Rows.Count, "#E:RowCount");
				pkRow = schema.Select ("ColumnName = 'id'") [0];
				Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#E:ColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["ColumnName"], "#E:ColumnName_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#E:ColumnOrdinal_IsNull");
				Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#E:ColumnOrdinal_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#E:ColumnSize_IsNull");
				Assert.AreEqual (4, pkRow ["ColumnSize"], "#E:ColumnSize_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#E:NumericPrecision_IsNull");
				Assert.AreEqual (10, pkRow ["NumericPrecision"], "#E:NumericPrecision_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#E:NumericScale_IsNull");
				Assert.AreEqual (0, pkRow ["NumericScale"], "#E:NumericScale_Value");
				Assert.IsFalse (pkRow.IsNull ("DataType"), "#E:DataType_IsNull");
				Assert.AreEqual (typeof (int), pkRow ["DataType"], "#E:DataType_Value");
				Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#E:ProviderType_IsNull");
				Assert.AreEqual (10, pkRow ["ProviderType"], "#E:ProviderType_Value");
				Assert.IsFalse (pkRow.IsNull ("IsLong"), "#E:IsLong_IsNull");
				Assert.AreEqual (false, pkRow ["IsLong"], "#E:IsLong_Value");
				Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#E:AllowDBNull_IsNull");
				Assert.AreEqual (false, pkRow ["AllowDBNull"], "#E:AllowDBNull_Value");
				Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#E:IsReadOnly_IsNull");
				Assert.AreEqual (false, pkRow ["IsReadOnly"], "#E:IsReadOnly_Value");
				Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#E:IsRowVersion_IsNull");
				Assert.AreEqual (false, pkRow ["IsRowVersion"], "#E:IsRowVersion_Value");
				Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#E:IsUnique_IsNull");
				Assert.AreEqual (true, pkRow ["IsUnique"], "#E:IsUnique_Value");
				Assert.IsFalse (pkRow.IsNull ("IsKey"), "#E:IsKey_IsNull");
				Assert.AreEqual (true, pkRow ["IsKey"], "#E:IsKey_Value");
				Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#E:IsAutoIncrement_IsNull");
				Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#E:IsAutoIncrement_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#E:BaseSchemaName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#E:BaseSchemaName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseCatalogName"), "#E:BaseCatalogName_IsNull");
				Assert.AreEqual ("monotest", pkRow ["BaseCatalogName"], "#E:BaseCatalogName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseTableName"), "#E:BaseTableName_IsNull");
				Assert.AreEqual ("employee", pkRow ["BaseTableName"], "#E:BaseTableName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseColumnName"), "#E:BaseColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["BaseColumnName"], "#E:BaseColumnName_Value");

				reader = cmd.ExecuteReader (CommandBehavior.SchemaOnly);
				schema = reader.GetSchemaTable ();
				reader.Close ();

				AssertSchemaTableStructure (schema, "#F:");
				Assert.AreEqual (3, schema.Rows.Count, "#F:RowCount");
				pkRow = schema.Select ("ColumnName = 'id'") [0];
				Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#F:ColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["ColumnName"], "#F:ColumnName_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#F:ColumnOrdinal_IsNull");
				Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#F:ColumnOrdinal_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#F:ColumnSize_IsNull");
				Assert.AreEqual (4, pkRow ["ColumnSize"], "#F:ColumnSize_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#F:NumericPrecision_IsNull");
				Assert.AreEqual (10, pkRow ["NumericPrecision"], "#F:NumericPrecision_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#F:NumericScale_IsNull");
				Assert.AreEqual (0, pkRow ["NumericScale"], "#F:NumericScale_Value");
				Assert.IsFalse (pkRow.IsNull ("DataType"), "#F:DataType_IsNull");
				Assert.AreEqual (typeof (int), pkRow ["DataType"], "#F:DataType_Value");
				Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#F:ProviderType_IsNull");
				Assert.AreEqual (10, pkRow ["ProviderType"], "#F:ProviderType_Value");
				Assert.IsFalse (pkRow.IsNull ("IsLong"), "#F:IsLong_IsNull");
				Assert.AreEqual (false, pkRow ["IsLong"], "#F:IsLong_Value");
				Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#F:AllowDBNull_IsNull");
				Assert.AreEqual (false, pkRow ["AllowDBNull"], "#F:AllowDBNull_Value");
				Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#F:IsReadOnly_IsNull");
				Assert.AreEqual (false, pkRow ["IsReadOnly"], "#F:IsReadOnly_Value");
				Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#F:IsRowVersion_IsNull");
				Assert.AreEqual (false, pkRow ["IsRowVersion"], "#F:IsRowVersion_Value");
				Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#F:IsUnique_IsNull");
				Assert.AreEqual (false, pkRow ["IsUnique"], "#F:IsUnique_Value");
				Assert.IsFalse (pkRow.IsNull ("IsKey"), "#F:IsKey_IsNull");
				Assert.AreEqual (false, pkRow ["IsKey"], "#F:IsKey_Value");
				Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#F:IsAutoIncrement_IsNull");
				Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#F:IsAutoIncrement_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#F:BaseSchemaName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#F:BaseSchemaName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseCatalogName"), "#F:BaseCatalogName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseCatalogName"], "#F:BaseCatalogName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseTableName"), "#F:BaseTableName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseTableName"], "#F:BaseTableName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseColumnName"), "#F:BaseColumnName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseColumnName"], "#F:BaseColumnName_Value");

				reader = cmd.ExecuteReader (CommandBehavior.KeyInfo);
				schema = reader.GetSchemaTable ();
				reader.Close ();

				AssertSchemaTableStructure (schema, "#G:");
				Assert.AreEqual (3, schema.Rows.Count, "#G:RowCount");
				pkRow = schema.Select ("ColumnName = 'id'") [0];
				Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#G:ColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["ColumnName"], "#G:ColumnName_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#G:ColumnOrdinal_IsNull");
				Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#G:ColumnOrdinal_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#G:ColumnSize_IsNull");
				Assert.AreEqual (4, pkRow ["ColumnSize"], "#G:ColumnSize_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#G:NumericPrecision_IsNull");
				Assert.AreEqual (10, pkRow ["NumericPrecision"], "#G:NumericPrecision_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#G:NumericScale_IsNull");
				Assert.AreEqual (0, pkRow ["NumericScale"], "#G:NumericScale_Value");
				Assert.IsFalse (pkRow.IsNull ("DataType"), "#G:DataType_IsNull");
				Assert.AreEqual (typeof (int), pkRow ["DataType"], "#G:DataType_Value");
				Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#G:ProviderType_IsNull");
				Assert.AreEqual (10, pkRow ["ProviderType"], "#G:ProviderType_Value");
				Assert.IsFalse (pkRow.IsNull ("IsLong"), "#G:IsLong_IsNull");
				Assert.AreEqual (false, pkRow ["IsLong"], "#G:IsLong_Value");
				Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#G:AllowDBNull_IsNull");
				Assert.AreEqual (false, pkRow ["AllowDBNull"], "#G:AllowDBNull_Value");
				Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#G:IsReadOnly_IsNull");
				Assert.AreEqual (false, pkRow ["IsReadOnly"], "#G:IsReadOnly_Value");
				Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#G:IsRowVersion_IsNull");
				Assert.AreEqual (false, pkRow ["IsRowVersion"], "#G:IsRowVersion_Value");
				Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#G:IsUnique_IsNull");
				Assert.AreEqual (true, pkRow ["IsUnique"], "#G:IsUnique_Value");
				Assert.IsFalse (pkRow.IsNull ("IsKey"), "#G:IsKey_IsNull");
				Assert.AreEqual (true, pkRow ["IsKey"], "#G:IsKey_Value");
				Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#G:IsAutoIncrement_IsNull");
				Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#G:IsAutoIncrement_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#G:BaseSchemaName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#G:BaseSchemaName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseCatalogName"), "#G:BaseCatalogName_IsNull");
				Assert.AreEqual ("monotest", pkRow ["BaseCatalogName"], "#G:BaseCatalogName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseTableName"), "#G:BaseTableName_IsNull");
				Assert.AreEqual ("employee", pkRow ["BaseTableName"], "#G:BaseTableName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseColumnName"), "#G:BaseColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["BaseColumnName"], "#G:BaseColumnName_Value");

				reader = cmd.ExecuteReader ();
				schema = reader.GetSchemaTable ();
				reader.Close ();

				AssertSchemaTableStructure (schema, "#H:");
				Assert.AreEqual (3, schema.Rows.Count, "#H:RowCount");
				pkRow = schema.Select ("ColumnName = 'id'") [0];
				Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#H:ColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["ColumnName"], "#H:ColumnName_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#H:ColumnOrdinal_IsNull");
				Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#H:ColumnOrdinal_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#H:ColumnSize_IsNull");
				Assert.AreEqual (4, pkRow ["ColumnSize"], "#H:ColumnSize_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#H:NumericPrecision_IsNull");
				Assert.AreEqual (10, pkRow ["NumericPrecision"], "#H:NumericPrecision_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#H:NumericScale_IsNull");
				Assert.AreEqual (0, pkRow ["NumericScale"], "#H:NumericScale_Value");
				Assert.IsFalse (pkRow.IsNull ("DataType"), "#H:DataType_IsNull");
				Assert.AreEqual (typeof (int), pkRow ["DataType"], "#H:DataType_Value");
				Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#H:ProviderType_IsNull");
				Assert.AreEqual (10, pkRow ["ProviderType"], "#H:ProviderType_Value");
				Assert.IsFalse (pkRow.IsNull ("IsLong"), "#H:IsLong_IsNull");
				Assert.AreEqual (false, pkRow ["IsLong"], "#H:IsLong_Value");
				Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#H:AllowDBNull_IsNull");
				Assert.AreEqual (false, pkRow ["AllowDBNull"], "#H:AllowDBNull_Value");
				Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#H:IsReadOnly_IsNull");
				Assert.AreEqual (false, pkRow ["IsReadOnly"], "#H:IsReadOnly_Value");
				Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#H:IsRowVersion_IsNull");
				Assert.AreEqual (false, pkRow ["IsRowVersion"], "#H:IsRowVersion_Value");
				Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#H:IsUnique_IsNull");
				Assert.AreEqual (false, pkRow ["IsUnique"], "#H:IsUnique_Value");
				Assert.IsFalse (pkRow.IsNull ("IsKey"), "#H:IsKey_IsNull");
				Assert.AreEqual (false, pkRow ["IsKey"], "#H:IsKey_Value");
				Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#H:IsAutoIncrement_IsNull");
				Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#H:IsAutoIncrement_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#H:BaseSchemaName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#H:BaseSchemaName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseCatalogName"), "#H:BaseCatalogName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseCatalogName"], "#H:BaseCatalogName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseTableName"), "#H:BaseTableName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseTableName"], "#H:BaseTableName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseColumnName"), "#H:BaseColumnName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseColumnName"], "#H:BaseColumnName_Value");

				cmd.CommandText = "select id, fname, id + 20 as plustwenty from employee where id = ?";
				IDbDataParameter param = cmd.CreateParameter ();
				cmd.Parameters.Add (param);
				param.DbType = DbType.Int32;
				param.Value = 2;
				reader = cmd.ExecuteReader (CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo);
				schema = reader.GetSchemaTable ();
				reader.Close ();

				AssertSchemaTableStructure (schema, "#I:");
				Assert.AreEqual (3, schema.Rows.Count, "#I:RowCount");
				pkRow = schema.Select ("ColumnName = 'id'") [0];
				Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#I:ColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["ColumnName"], "#I:ColumnName_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#I:ColumnOrdinal_IsNull");
				Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#I:ColumnOrdinal_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#I:ColumnSize_IsNull");
				Assert.AreEqual (4, pkRow ["ColumnSize"], "#I:ColumnSize_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#I:NumericPrecision_IsNull");
				Assert.AreEqual (10, pkRow ["NumericPrecision"], "#I:NumericPrecision_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#I:NumericScale_IsNull");
				Assert.AreEqual (0, pkRow ["NumericScale"], "#I:NumericScale_Value");
				Assert.IsFalse (pkRow.IsNull ("DataType"), "#I:DataType_IsNull");
				Assert.AreEqual (typeof (int), pkRow ["DataType"], "#I:DataType_Value");
				Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#I:ProviderType_IsNull");
				Assert.AreEqual (10, pkRow ["ProviderType"], "#I:ProviderType_Value");
				Assert.IsFalse (pkRow.IsNull ("IsLong"), "#I:IsLong_IsNull");
				Assert.AreEqual (false, pkRow ["IsLong"], "#I:IsLong_Value");
				Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#I:AllowDBNull_IsNull");
				Assert.AreEqual (false, pkRow ["AllowDBNull"], "#I:AllowDBNull_Value");
				Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#I:IsReadOnly_IsNull");
				Assert.AreEqual (false, pkRow ["IsReadOnly"], "#I:IsReadOnly_Value");
				Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#I:IsRowVersion_IsNull");
				Assert.AreEqual (false, pkRow ["IsRowVersion"], "#I:IsRowVersion_Value");
				Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#I:IsUnique_IsNull");
				Assert.AreEqual (true, pkRow ["IsUnique"], "#I:IsUnique_Value");
				Assert.IsFalse (pkRow.IsNull ("IsKey"), "#I:IsKey_IsNull");
				Assert.AreEqual (true, pkRow ["IsKey"], "#I:IsKey_Value");
				Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#I:IsAutoIncrement_IsNull");
				Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#I:IsAutoIncrement_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#I:BaseSchemaName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#I:BaseSchemaName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseCatalogName"), "#I:BaseCatalogName_IsNull");
				Assert.AreEqual ("monotest", pkRow ["BaseCatalogName"], "#I:BaseCatalogName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseTableName"), "#I:BaseTableName_IsNull");
				Assert.AreEqual ("employee", pkRow ["BaseTableName"], "#I:BaseTableName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseColumnName"), "#I:BaseColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["BaseColumnName"], "#I:BaseColumnName_Value");

				reader = cmd.ExecuteReader (CommandBehavior.SchemaOnly);
				schema = reader.GetSchemaTable ();
				reader.Close ();

				AssertSchemaTableStructure (schema, "#J:");
				Assert.AreEqual (3, schema.Rows.Count, "#J:RowCount");
				pkRow = schema.Select ("ColumnName = 'id'") [0];
				Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#J:ColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["ColumnName"], "#J:ColumnName_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#J:ColumnOrdinal_IsNull");
				Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#J:ColumnOrdinal_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#J:ColumnSize_IsNull");
				Assert.AreEqual (4, pkRow ["ColumnSize"], "#J:ColumnSize_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#J:NumericPrecision_IsNull");
				Assert.AreEqual (10, pkRow ["NumericPrecision"], "#J:NumericPrecision_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#J:NumericScale_IsNull");
				Assert.AreEqual (0, pkRow ["NumericScale"], "#J:NumericScale_Value");
				Assert.IsFalse (pkRow.IsNull ("DataType"), "#J:DataType_IsNull");
				Assert.AreEqual (typeof (int), pkRow ["DataType"], "#J:DataType_Value");
				Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#J:ProviderType_IsNull");
				Assert.AreEqual (10, pkRow ["ProviderType"], "#J:ProviderType_Value");
				Assert.IsFalse (pkRow.IsNull ("IsLong"), "#J:IsLong_IsNull");
				Assert.AreEqual (false, pkRow ["IsLong"], "#J:IsLong_Value");
				Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#J:AllowDBNull_IsNull");
				Assert.AreEqual (false, pkRow ["AllowDBNull"], "#J:AllowDBNull_Value");
				Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#J:IsReadOnly_IsNull");
				Assert.AreEqual (false, pkRow ["IsReadOnly"], "#J:IsReadOnly_Value");
				Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#J:IsRowVersion_IsNull");
				Assert.AreEqual (false, pkRow ["IsRowVersion"], "#J:IsRowVersion_Value");
				Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#J:IsUnique_IsNull");
				Assert.AreEqual (false, pkRow ["IsUnique"], "#J:IsUnique_Value");
				Assert.IsFalse (pkRow.IsNull ("IsKey"), "#J:IsKey_IsNull");
				Assert.AreEqual (false, pkRow ["IsKey"], "#J:IsKey_Value");
				Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#J:IsAutoIncrement_IsNull");
				Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#J:IsAutoIncrement_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#J:BaseSchemaName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#J:BaseSchemaName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseCatalogName"), "#J:BaseCatalogName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseCatalogName"], "#J:BaseCatalogName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseTableName"), "#J:BaseTableName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseTableName"], "#J:BaseTableName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseColumnName"), "#J:BaseColumnName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseColumnName"], "#J:BaseColumnName_Value");

				reader = cmd.ExecuteReader (CommandBehavior.KeyInfo);
				schema = reader.GetSchemaTable ();
				reader.Close ();

				AssertSchemaTableStructure (schema, "#K:");
				Assert.AreEqual (3, schema.Rows.Count, "#K:RowCount");
				pkRow = schema.Select ("ColumnName = 'id'") [0];
				Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#K:ColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["ColumnName"], "#K:ColumnName_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#K:ColumnOrdinal_IsNull");
				Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#K:ColumnOrdinal_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#K:ColumnSize_IsNull");
				Assert.AreEqual (4, pkRow ["ColumnSize"], "#K:ColumnSize_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#K:NumericPrecision_IsNull");
				Assert.AreEqual (10, pkRow ["NumericPrecision"], "#K:NumericPrecision_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#K:NumericScale_IsNull");
				Assert.AreEqual (0, pkRow ["NumericScale"], "#K:NumericScale_Value");
				Assert.IsFalse (pkRow.IsNull ("DataType"), "#K:DataType_IsNull");
				Assert.AreEqual (typeof (int), pkRow ["DataType"], "#K:DataType_Value");
				Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#K:ProviderType_IsNull");
				Assert.AreEqual (10, pkRow ["ProviderType"], "#K:ProviderType_Value");
				Assert.IsFalse (pkRow.IsNull ("IsLong"), "#K:IsLong_IsNull");
				Assert.AreEqual (false, pkRow ["IsLong"], "#K:IsLong_Value");
				Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#K:AllowDBNull_IsNull");
				Assert.AreEqual (false, pkRow ["AllowDBNull"], "#K:AllowDBNull_Value");
				Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#K:IsReadOnly_IsNull");
				Assert.AreEqual (false, pkRow ["IsReadOnly"], "#K:IsReadOnly_Value");
				Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#K:IsRowVersion_IsNull");
				Assert.AreEqual (false, pkRow ["IsRowVersion"], "#K:IsRowVersion_Value");
				Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#K:IsUnique_IsNull");
				Assert.AreEqual (true, pkRow ["IsUnique"], "#K:IsUnique_Value");
				Assert.IsFalse (pkRow.IsNull ("IsKey"), "#K:IsKey_IsNull");
				Assert.AreEqual (true, pkRow ["IsKey"], "#K:IsKey_Value");
				Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#K:IsAutoIncrement_IsNull");
				Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#K:IsAutoIncrement_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#K:BaseSchemaName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#K:BaseSchemaName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseCatalogName"), "#K:BaseCatalogName_IsNull");
				Assert.AreEqual ("monotest", pkRow ["BaseCatalogName"], "#K:BaseCatalogName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseTableName"), "#K:BaseTableName_IsNull");
				Assert.AreEqual ("employee", pkRow ["BaseTableName"], "#K:BaseTableName_Value");
				Assert.IsFalse (pkRow.IsNull ("BaseColumnName"), "#K:BaseColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["BaseColumnName"], "#K:BaseColumnName_Value");

				reader = cmd.ExecuteReader ();
				schema = reader.GetSchemaTable ();
				reader.Close ();

				AssertSchemaTableStructure (schema, "#L:");
				Assert.AreEqual (3, schema.Rows.Count, "#L:RowCount");
				pkRow = schema.Select ("ColumnName = 'id'") [0];
				Assert.IsFalse (pkRow.IsNull ("ColumnName"), "#L:ColumnName_IsNull");
				Assert.AreEqual ("id", pkRow ["ColumnName"], "#L:ColumnName_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnOrdinal"), "#L:ColumnOrdinal_IsNull");
				Assert.AreEqual (0, pkRow ["ColumnOrdinal"], "#L:ColumnOrdinal_Value");
				Assert.IsFalse (pkRow.IsNull ("ColumnSize"), "#L:ColumnSize_IsNull");
				Assert.AreEqual (4, pkRow ["ColumnSize"], "#L:ColumnSize_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericPrecision"), "#L:NumericPrecision_IsNull");
				Assert.AreEqual (10, pkRow ["NumericPrecision"], "#L:NumericPrecision_Value");
				Assert.IsFalse (pkRow.IsNull ("NumericScale"), "#L:NumericScale_IsNull");
				Assert.AreEqual (0, pkRow ["NumericScale"], "#L:NumericScale_Value");
				Assert.IsFalse (pkRow.IsNull ("DataType"), "#L:DataType_IsNull");
				Assert.AreEqual (typeof (int), pkRow ["DataType"], "#L:DataType_Value");
				Assert.IsFalse (pkRow.IsNull ("ProviderType"), "#L:ProviderType_IsNull");
				Assert.AreEqual (10, pkRow ["ProviderType"], "#L:ProviderType_Value");
				Assert.IsFalse (pkRow.IsNull ("IsLong"), "#L:IsLong_IsNull");
				Assert.AreEqual (false, pkRow ["IsLong"], "#L:IsLong_Value");
				Assert.IsFalse (pkRow.IsNull ("AllowDBNull"), "#L:AllowDBNull_IsNull");
				Assert.AreEqual (false, pkRow ["AllowDBNull"], "#L:AllowDBNull_Value");
				Assert.IsFalse (pkRow.IsNull ("IsReadOnly"), "#L:IsReadOnly_IsNull");
				Assert.AreEqual (false, pkRow ["IsReadOnly"], "#L:IsReadOnly_Value");
				Assert.IsFalse (pkRow.IsNull ("IsRowVersion"), "#L:IsRowVersion_IsNull");
				Assert.AreEqual (false, pkRow ["IsRowVersion"], "#L:IsRowVersion_Value");
				Assert.IsFalse (pkRow.IsNull ("IsUnique"), "#L:IsUnique_IsNull");
				Assert.AreEqual (false, pkRow ["IsUnique"], "#L:IsUnique_Value");
				Assert.IsFalse (pkRow.IsNull ("IsKey"), "#L:IsKey_IsNull");
				Assert.AreEqual (false, pkRow ["IsKey"], "#L:IsKey_Value");
				Assert.IsFalse (pkRow.IsNull ("IsAutoIncrement"), "#L:IsAutoIncrement_IsNull");
				Assert.AreEqual (false, pkRow ["IsAutoIncrement"], "#L:IsAutoIncrement_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseSchemaName"), "#L:BaseSchemaName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseSchemaName"], "#L:BaseSchemaName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseCatalogName"), "#L:BaseCatalogName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseCatalogName"], "#L:BaseCatalogName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseTableName"), "#L:BaseTableName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseTableName"], "#L:BaseTableName_Value");
				Assert.IsTrue (pkRow.IsNull ("BaseColumnName"), "#L:BaseColumnName_IsNull");
				Assert.AreEqual (DBNull.Value, pkRow ["BaseColumnName"], "#L:BaseColumnName_Value");
			} finally {
				if (reader != null)
					reader.Close ();
			}
		}
Exemplo n.º 15
0
Arquivo: test.cs Projeto: mono/gert
	static int Main ()
	{
		if (Environment.GetEnvironmentVariable ("MONO_TESTS_ODBC") == null)
			return 0;

		OdbcConnection conn = new OdbcConnection (CreateOdbcConnectionString ());
		conn.Open ();

		OdbcCommand cmd = new OdbcCommand (drop_table, conn);
		cmd.ExecuteNonQuery ();

		try {
			cmd = new OdbcCommand (create_table, conn);
			cmd.ExecuteNonQuery ();

			cmd = new OdbcCommand (insert_data, conn);
			cmd.ExecuteNonQuery ();

			cmd = new OdbcCommand ("DELEERER", conn);
			try {
				cmd.ExecuteNonQuery ();
				return 1;
			} catch (OdbcException) {
			}

			conn.Dispose ();
			conn = null;
		} finally {
			if (conn == null) {
				conn = new OdbcConnection (CreateOdbcConnectionString ());
				conn.Open ();
			}

			cmd = new OdbcCommand (drop_table, conn);
			cmd.ExecuteNonQuery ();
			cmd.Dispose ();

			conn.Dispose ();
		}

		conn = new OdbcConnection (CreateOdbcConnectionString ());
		conn.Open ();

		try {
			cmd = new OdbcCommand (create_table, conn);
			cmd.ExecuteNonQuery ();

			cmd = new OdbcCommand (insert_data, conn);
			cmd.ExecuteNonQuery ();

			cmd = new OdbcCommand (delete_data, conn);
			cmd.Prepare ();
			cmd.ExecuteNonQuery ();

			conn.Dispose ();
			cmd.Dispose ();

			conn = null;
			cmd = null;
		} finally {
			if (conn == null) {
				conn = new OdbcConnection (CreateOdbcConnectionString ());
				conn.Open ();
			}

			cmd = new OdbcCommand (drop_table, conn);
			cmd.ExecuteNonQuery ();

			conn.Dispose ();
		}

		return 0;
	}