示例#1
0
    /// <summary>
    /// Test CUBRIDCommand column properties
    /// </summary>
    private static void Test_Command_ColumnProperties()
    {
      using (CUBRIDConnection conn = new CUBRIDConnection())
      {
        conn.ConnectionString = TestCases.connString;
        conn.Open();

        String sql = "select * from nation";
        CUBRIDCommand cmd = new CUBRIDCommand(sql, conn);
        CUBRIDCommand cmd2 = cmd.Clone();

        try
        {
            cmd.Cancel();
        }
        catch (Exception e)
        {
            string r = "System.NotSupportedException: Specified method is not supported";
            Debug.Assert(e.Message.Substring(0,r.Length) == r);
        }

        Debug.Assert(cmd.CommandType == cmd2.CommandType);
        CUBRIDDataAdapter da = new CUBRIDDataAdapter();
        da.SelectCommand = cmd;
        DataTable dt = new DataTable("");
        da.FillSchema(dt, SchemaType.Source);//To retrieve all the column properties you have to use the FillSchema() method

        Debug.Assert(cmd.ColumnInfos[0].Name == "code");
        Debug.Assert(cmd.ColumnInfos[0].IsPrimaryKey == true);
        Debug.Assert(cmd.ColumnInfos[0].IsForeignKey == false);
        Debug.Assert(cmd.ColumnInfos[0].IsNullable == false);
        Debug.Assert(cmd.ColumnInfos[0].RealName == "");
        Debug.Assert(cmd.ColumnInfos[0].Precision == 3);
        Debug.Assert(cmd.ColumnInfos[0].Scale == 0);
        Debug.Assert(cmd.ColumnInfos[0].IsAutoIncrement == false);
        Debug.Assert(cmd.ColumnInfos[0].IsReverseIndex == false);
        Debug.Assert(cmd.ColumnInfos[0].IsReverseUnique == false);
        Debug.Assert(cmd.ColumnInfos[0].IsShared == false);
        Debug.Assert(cmd.ColumnInfos[0].Type == CUBRIDDataType.CCI_U_TYPE_CHAR);
        Debug.Assert(cmd.ColumnInfos[0].Table == "nation");
      }
    }