本文整理汇总了C#中CUBRID.Data.CUBRIDClient.CUBRIDConnection.GetSchema方法的典型用法代码示例。如果您正苦于以下问题:C# CUBRIDConnection.GetSchema方法的具体用法?C# CUBRIDConnection.GetSchema怎么用?C# CUBRIDConnection.GetSchema使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUBRID.Data.CUBRIDClient.CUBRIDConnection
的用法示例。
在下文中一共展示了CUBRIDConnection.GetSchema方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: APIS_728
public void APIS_728()
{
CUBRIDConnection conn = new CUBRIDConnection();
conn.ConnectionString = "server=test-db-server;database=demodb;port=33000;user=dba;password=";
try
{
DataTable dt = conn.GetSchema("TABLES");
}
catch (Exception e)
{
Assert.AreEqual("The connection is not open!", e.Message);
}
conn.Open();
DataTable dt_test = conn.GetSchema("TABLES");
Assert.IsNotNull(dt_test);
dt_test = conn.GetSchema("ReservedWords");
Assert.IsNotNull(dt_test);
dt_test = conn.GetSchema("Users");
Assert.IsNotNull(dt_test);
dt_test = conn.GetSchema("Databases");
Assert.IsNotNull(dt_test);
dt_test = conn.GetSchema("Views");
Assert.IsNotNull(dt_test);
dt_test = conn.GetSchema("Columns", new String[] { "game", "event_code" });
Assert.IsNotNull(dt_test);
dt_test = conn.GetSchema("Indexes", new String[] { "nation", "code" });
Assert.IsNotNull(dt_test);
dt_test = conn.GetSchema("Index_Columns", new String[] { "nation", "pk_nation_code" });
Assert.IsNotNull(dt_test);
dt_test = conn.GetSchema("FOREIGN_KEYS", new String[] { "game", "fk_game_athlete_code" });
Assert.IsNotNull(dt_test);
dt_test = conn.GetSchema("INVALID");
Assert.IsNull(dt_test);
conn.Close();
}
示例2: APIS_727
public void APIS_727()
{
CUBRIDConnection conn = new CUBRIDConnection();
conn.ConnectionString = "server=test-db-server;database=demodb;port=33000;user=dba;password=";
conn.Open();
try
{
DataTable dt = conn.GetSchema(null);
}
catch (ArgumentException e)
{
Console.WriteLine(e.Message);
Assert.AreEqual("The collectionName is specified as null.!", e.Message);
}
conn.Close();
}
示例3: Test_ConnectionGetSchema
/// <summary>
/// Test CUBRIDConnection GetSchema() method
/// </summary>
private static void Test_ConnectionGetSchema()
{
using (CUBRIDConnection conn = new CUBRIDConnection())
{
conn.ConnectionString = TestCases.connString;
conn.Open();
DataTable dt = new DataTable();
dt = conn.GetSchema("USERS");
Debug.Assert(dt.Rows.Count == 2);
Debug.Assert(dt.Rows[0]["USERNAME"].ToString() == "DBA");
Debug.Assert(dt.Rows[1]["USERNAME"].ToString() == "PUBLIC");
dt = conn.GetSchema("DATABASES");
Debug.Assert(dt.Rows.Count == 1);
Debug.Assert(dt.Rows[0]["CATALOG_NAME"].ToString() == "demodb");
Debug.Assert(dt.Rows[0]["SCHEMA_NAME"].ToString() == "demodb");
dt = conn.GetSchema("PROCEDURES");
Debug.Assert(dt.Rows.Count == 0);
dt = conn.GetSchema("TABLES", new String[] { "nation" });
Debug.Assert(dt.Rows.Count == 1);
Debug.Assert(dt.Rows[0]["TABLE_CATALOG"].ToString() == "demodb");
Debug.Assert(dt.Rows[0]["TABLE_SCHEMA"].ToString() == "demodb");
Debug.Assert(dt.Rows[0]["TABLE_NAME"].ToString() == "nation");
dt = conn.GetSchema("VIEWS");
Debug.Assert(dt.Columns.Count == 3);
Debug.Assert(dt.Columns[0].ColumnName == "VIEW_CATALOG");
Debug.Assert(dt.Columns[1].ColumnName == "VIEW_SCHEMA");
Debug.Assert(dt.Columns[2].ColumnName == "VIEW_NAME");
Debug.Assert(dt.Rows.Count == 0);
dt = conn.GetSchema("COLUMNS", new String[] { "game", "event_code" });
Debug.Assert(dt.Rows.Count == 1);
Debug.Assert(dt.Rows[0]["TABLE_CATALOG"].ToString() == "demodb");
Debug.Assert(dt.Rows[0]["TABLE_SCHEMA"].ToString() == "demodb");
Debug.Assert(dt.Rows[0]["TABLE_NAME"].ToString() == "game");
Debug.Assert(dt.Rows[0]["COLUMN_NAME"].ToString() == "event_code");
Debug.Assert((uint)dt.Rows[0]["ORDINAL_POSITION"] == (uint)1);
Debug.Assert(dt.Rows[0]["COLUMN_DEFAULT"].ToString() == "");
Debug.Assert((bool)dt.Rows[0]["IS_NULLABLE"] == false);
Debug.Assert(dt.Rows[0]["DATA_TYPE"].ToString() == "INTEGER");
Debug.Assert((uint)dt.Rows[0]["NUMERIC_PRECISION"] == (uint)10);
Debug.Assert((uint)dt.Rows[0]["NUMERIC_SCALE"] == (uint)0);
Debug.Assert((byte)dt.Rows[0]["CHARACTER_SET"] == (byte)0);
dt = conn.GetSchema("INDEXES", new String[] { "nation", "code" });
Debug.Assert(dt.Rows.Count == 1);
Debug.Assert(dt.Rows[0]["INDEX_CATALOG"].ToString() == "demodb");
Debug.Assert(dt.Rows[0]["INDEX_SCHEMA"].ToString() == "demodb");
Debug.Assert(dt.Rows[0]["INDEX_NAME"].ToString() == "pk_nation_code");
Debug.Assert(dt.Rows[0]["TABLE_NAME"].ToString() == "nation");
Debug.Assert((bool)dt.Rows[0]["UNIQUE"] == true);
Debug.Assert((bool)dt.Rows[0]["REVERSE"] == false);
Debug.Assert((bool)dt.Rows[0]["PRIMARY"] == true);
Debug.Assert((bool)dt.Rows[0]["FOREIGN_KEY"] == false);
Debug.Assert(dt.Rows[0]["DIRECTION"].ToString() == "ASC");
dt = conn.GetSchema("INDEX_COLUMNS", new String[] { "nation", "pk_nation_code" });
Debug.Assert(dt.Rows.Count == 1);
Debug.Assert(dt.Rows[0]["INDEX_CATALOG"].ToString() == "demodb");
Debug.Assert(dt.Rows[0]["INDEX_SCHEMA"].ToString() == "demodb");
Debug.Assert(dt.Rows[0]["INDEX_NAME"].ToString() == "pk_nation_code");
Debug.Assert(dt.Rows[0]["TABLE_NAME"].ToString() == "nation");
Debug.Assert(dt.Rows[0]["COLUMN_NAME"].ToString() == "code");
Debug.Assert((int)dt.Rows[0]["ORDINAL_POSITION"] == 0);
Debug.Assert(dt.Rows[0]["DIRECTION"].ToString() == "ASC");
dt = conn.GetSchema("FOREIGN_KEYS", new String[] { "game", "fk_game_athlete_code" });
Debug.Assert(dt.Rows.Count == 2);
Debug.Assert(dt.Rows[0]["PKTABLE_NAME"].ToString() == "event");
Debug.Assert(dt.Rows[0]["PKCOLUMN_NAME"].ToString() == "code");
Debug.Assert(dt.Rows[0]["FKTABLE_NAME"].ToString() == "game");
Debug.Assert(dt.Rows[0]["FKCOLUMN_NAME"].ToString() == "event_code");
Debug.Assert((short)dt.Rows[0]["KEY_SEQ"] == (short)1);
Debug.Assert((short)dt.Rows[0]["UPDATE_ACTION"] == (short)1);
Debug.Assert((short)dt.Rows[0]["DELETE_ACTION"] == (short)1);
Debug.Assert(dt.Rows[0]["FK_NAME"].ToString() == "fk_game_event_code");
Debug.Assert(dt.Rows[0]["PK_NAME"].ToString() == "pk_event_code");
conn.Close();
}
}
示例4: GetSchema_SchemaName_Test
public void GetSchema_SchemaName_Test()
{
using (CUBRIDConnection conn = new CUBRIDConnection())
{
conn.ConnectionString = DBHelper.connString;
conn.Open();
Log("Test GetSchema with specified schema name");
LogTestStep("Test USERS");
DataTable dt = conn.GetSchema("USERS");
if (dt != null)
{
Assert.AreEqual(2, dt.Rows.Count);
Assert.AreEqual("DBA", dt.Rows[0]["USERNAME"].ToString());
Assert.AreEqual("PUBLIC", dt.Rows[1]["USERNAME"].ToString());
LogStepPass();
}
else
{
LogStepFail();
}
LogTestStep("Test DATABASES");
dt = conn.GetSchema("DATABASES");
if (dt != null)
{
Assert.AreEqual(1, dt.Rows.Count);
Assert.AreEqual("demodb", dt.Rows[0]["CATALOG_NAME"].ToString());
Assert.AreEqual("demodb", dt.Rows[0]["SCHEMA_NAME"].ToString());
LogStepPass();
}
else
{
LogStepFail();
}
LogTestStep("Test VIEWS");
dt = conn.GetSchema("VIEWS");
if (dt != null)
{
Assert.AreEqual(3, dt.Columns.Count);
Assert.AreEqual("VIEW_CATALOG", dt.Columns[0].ColumnName);
Assert.AreEqual("VIEW_SCHEMA", dt.Columns[1].ColumnName);
Assert.AreEqual("VIEW_NAME", dt.Columns[2].ColumnName);
Assert.AreEqual(11, dt.Rows.Count);
LogStepPass();
}
else
{
LogStepFail();
}
// question 1
//LogTestStep("Test TABLES");
//dt = conn.GetSchema("TABLES");
//if (dt != null)
//{
// Assert.AreEqual(3, dt.Columns.Count);
// Assert.AreEqual("TABLE_CATALOG", dt.Columns[0].ColumnName);
// Assert.AreEqual("TABLE_SCHEMA", dt.Columns[1].ColumnName);
// Assert.AreEqual("TABLE_NAME", dt.Columns[2].ColumnName);
// Assert.AreEqual(0, dt.Rows.Count);
//}
LogTestStep("Test RESERVED_WORDS");
dt = conn.GetSchema("RESERVED_WORDS");
if (dt != null)
{
List<string> wordList = new List<string>();
using (StreamReader sr = new StreamReader(@"..\..\..\ADOTest\Resource\ReservedKeyWords.txt"))
{
string s = null;
while ((s = sr.ReadLine()) != null)
{
wordList.Add(s.Trim());
}
}
Assert.AreEqual(wordList.Count, dt.Rows.Count);
foreach (string s in wordList)
{
if (!dt.Rows.Contains(s))
{
LogStepFail();
Assert.Fail(String.Format("Reservered word {0} is missing", s));
}
}
LogStepPass();
}
else
{
LogStepFail();
}
LogTestResult();
}
}
示例5: GetSchema_NameAndFilter_Test
public void GetSchema_NameAndFilter_Test()
{
using (CUBRIDConnection conn = new CUBRIDConnection())
{
conn.ConnectionString = DBHelper.connString;
conn.Open();
Log("Test GetSchema with specified schema name and restriction values");
LogTestStep("Test TABLES");
DataTable dt = conn.GetSchema("TABLES", new String[] { "nation" });
if (dt != null)
{
Assert.AreEqual(1, dt.Rows.Count);
Assert.AreEqual("demodb", dt.Rows[0]["TABLE_CATALOG"].ToString());
Assert.AreEqual("demodb", dt.Rows[0]["TABLE_SCHEMA"].ToString());
Assert.AreEqual("nation", dt.Rows[0]["TABLE_NAME"].ToString());
LogStepPass();
}
else
{
LogStepFail();
}
LogTestStep("Test COLUMNS");
dt = conn.GetSchema("COLUMNS", new String[] { "game", "event_code" });
if (dt != null)
{
Assert.AreEqual(1, dt.Rows.Count);
Assert.AreEqual("demodb", dt.Rows[0]["TABLE_CATALOG"].ToString());
Assert.AreEqual("demodb", dt.Rows[0]["TABLE_SCHEMA"].ToString());
Assert.AreEqual("game", dt.Rows[0]["TABLE_NAME"].ToString());
Assert.AreEqual("event_code", dt.Rows[0]["COLUMN_NAME"].ToString());
Assert.AreEqual((uint)1, (uint)dt.Rows[0]["ORDINAL_POSITION"]);
Assert.AreEqual("", dt.Rows[0]["COLUMN_DEFAULT"].ToString());
Assert.AreEqual(false, (bool)dt.Rows[0]["IS_NULLABLE"]);
Assert.AreEqual("INTEGER", dt.Rows[0]["DATA_TYPE"].ToString());
Assert.AreEqual((uint)10, (uint)dt.Rows[0]["NUMERIC_PRECISION"]);
Assert.AreEqual((uint)0, (uint)dt.Rows[0]["NUMERIC_SCALE"]);
Assert.AreEqual((byte)0, (byte)dt.Rows[0]["CHARACTER_SET"]);
LogStepPass();
}
else
{
LogStepFail();
}
LogTestStep("Test INDEXES");
dt = conn.GetSchema("INDEXES", new String[] { "nation", "code" });
if (dt != null)
{
Assert.AreEqual(1, dt.Rows.Count);
Assert.AreEqual("demodb", dt.Rows[0]["INDEX_CATALOG"].ToString());
Assert.AreEqual("demodb", dt.Rows[0]["INDEX_SCHEMA"].ToString());
Assert.AreEqual("pk_nation_code", dt.Rows[0]["INDEX_NAME"].ToString());
Assert.AreEqual("nation", dt.Rows[0]["TABLE_NAME"].ToString());
Assert.AreEqual(true, (bool)dt.Rows[0]["UNIQUE"]);
Assert.AreEqual(false, (bool)dt.Rows[0]["REVERSE"]);
Assert.AreEqual(true, (bool)dt.Rows[0]["PRIMARY"]);
Assert.AreEqual(false, (bool)dt.Rows[0]["FOREIGN_KEY"]);
Assert.AreEqual("ASC", dt.Rows[0]["DIRECTION"].ToString());
LogStepPass();
}
else
{
LogStepFail();
}
LogTestStep("Test INDEXE_COLUMNS");
dt = conn.GetSchema("INDEX_COLUMNS", new String[] { "nation", "pk_nation_code" });
if (dt != null)
{
Assert.AreEqual(1, dt.Rows.Count);
Assert.AreEqual("demodb", dt.Rows[0]["INDEX_CATALOG"].ToString());
Assert.AreEqual("demodb", dt.Rows[0]["INDEX_SCHEMA"].ToString());
Assert.AreEqual("pk_nation_code", dt.Rows[0]["INDEX_NAME"].ToString());
Assert.AreEqual("nation", dt.Rows[0]["TABLE_NAME"].ToString());
Assert.AreEqual("code", dt.Rows[0]["COLUMN_NAME"].ToString());
Assert.AreEqual(0, (int)dt.Rows[0]["ORDINAL_POSITION"]);
Assert.AreEqual("ASC", dt.Rows[0]["DIRECTION"].ToString());
LogStepPass();
}
else
{
LogStepFail();
}
Log("Test FOREIGN_KEYS");
dt = conn.GetSchema("FOREIGN_KEYS", new String[] { "game", "fk_game_athlete_code" });
if (dt != null)
{
Assert.AreEqual(2, dt.Rows.Count);
//Assert.AreEqual("athlete", dt.Rows[0]["PKTABLE_NAME"].ToString());
Assert.AreEqual("code", dt.Rows[0]["PKCOLUMN_NAME"].ToString());
Assert.AreEqual("game", dt.Rows[0]["FKTABLE_NAME"].ToString());
//Assert.AreEqual("athlete_code", dt.Rows[0]["FKCOLUMN_NAME"].ToString());
Assert.AreEqual((short)1, (short)dt.Rows[0]["KEY_SEQ"]);
Assert.AreEqual((short)1, (short)dt.Rows[0]["UPDATE_ACTION"]);
Assert.AreEqual((short)1, (short)dt.Rows[0]["DELETE_ACTION"]);
//Assert.AreEqual("fk_game_athlete_code", dt.Rows[0]["FK_NAME"].ToString());
//.........这里部分代码省略.........
示例6: GetSchema_Negtive_Test
public void GetSchema_Negtive_Test()
{
using (CUBRIDConnection conn = new CUBRIDConnection())
{
conn.ConnectionString = DBHelper.connString;
conn.Open();
LogTestStep("Test GetSchema() with collectionName as null");
DataTable dt = null;
string schemaName = null;
try
{
dt = conn.GetSchema(schemaName);
LogStepFail();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
//Assert.AreEqual("some message here", ex.Message);
LogStepPass();
}
Log("The ArgumentException is not thrown");
LogTestStep("Test GetSchema(String, String[]) with collectionName as null");
try
{
dt = conn.GetSchema(schemaName, new String[] { "nation" });
LogStepFail();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
//Assert.AreEqual("some message here", ex.Message);
LogStepPass();
}
Log("The ArgumentException is not thrown");
LogTestResult();
}
}