本文整理汇总了C#中CUBRID.Data.CUBRIDClient.CUBRIDConnection.CreateCommand方法的典型用法代码示例。如果您正苦于以下问题:C# CUBRIDConnection.CreateCommand方法的具体用法?C# CUBRIDConnection.CreateCommand怎么用?C# CUBRIDConnection.CreateCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUBRID.Data.CUBRIDClient.CUBRIDConnection
的用法示例。
在下文中一共展示了CUBRIDConnection.CreateCommand方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSequences
public List<string> GetSequences(List<Table> tables)
{
var sequences = new List<string>();
var conn = new CUBRIDConnection(connectionStr);
conn.Open();
try
{
using (conn)
{
CUBRIDCommand seqCommand = conn.CreateCommand();
seqCommand.CommandText = "select [name], class_name from db_serial";
var seqReader = (CUBRIDDataReader)seqCommand.ExecuteReader(CommandBehavior.CloseConnection);
while (seqReader.Read())
{
sequences.AddRange(from table in tables where table.Name.ToUpper() == seqReader.GetString(1).ToUpper() select seqReader.GetString(0));
}
}
}
finally
{
conn.Close();
}
return sequences;
}
示例2: CreateCommand_Test
public void CreateCommand_Test()
{
using (CUBRIDConnection conn = new CUBRIDConnection())
{
conn.ConnectionString = DBHelper.connString;
conn.Open();
DBHelper.ExecuteSQL("drop table if exists t", conn);
CUBRIDCommand cmd = conn.CreateCommand();
cmd.CommandText = "create table t(idx integer)";
cmd.ExecuteNonQuery();
int tablesCount = DBHelper.GetTablesCount("t", conn);
Assert.AreEqual(1, tablesCount);
//revert the test db
DBHelper.ExecuteSQL("drop table t", conn);
LogTestResult();
}
}
示例3: Test_Command_Multiple_CommandText
/// <summary>
/// Test basic SQL statements execution, using parameters
/// </summary>
private static void Test_Command_Multiple_CommandText()
{
string sqlTablesCount = "select count(*) from db_class";
int tablesCount, newTableCount;
using (CUBRIDConnection conn = new CUBRIDConnection())
{
conn.ConnectionString = TestCases.connString;
conn.Open();
using (CUBRIDCommand cmd = conn.CreateCommand())
{
tablesCount = (int)TestCases.GetSingleValue(sqlTablesCount, conn);
cmd.CommandText = "create table test(id int)";
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
newTableCount = (int)TestCases.GetSingleValue(sqlTablesCount, conn);
Debug.Assert(newTableCount == tablesCount + 1);
cmd.CommandText = "drop table test";
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
newTableCount = (int)TestCases.GetSingleValue(sqlTablesCount, conn);
Debug.Assert(newTableCount == tablesCount);
}
}
}