本文整理汇总了C#中DbCommand.ExecuteCommand方法的典型用法代码示例。如果您正苦于以下问题:C# DbCommand.ExecuteCommand方法的具体用法?C# DbCommand.ExecuteCommand怎么用?C# DbCommand.ExecuteCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbCommand
的用法示例。
在下文中一共展示了DbCommand.ExecuteCommand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DbCommand
private void DbCommand()
{
while (true)
{
Console.Clear();
Console.WriteLine("\n1 - Send a SQL command");
Console.WriteLine("2 - Send an NULL SQL command");
Console.WriteLine("3 - Send an Oracle command");
Console.WriteLine("4 - Send an NULL Oracle command");
Console.Write("\nChoose a menu item number, or press any other key return to previous menu: ");
var input = Console.ReadKey();
var test = input.KeyChar;
Console.Clear();
Console.Write("Enter a command to send: ");
var commandInput = Console.ReadLine();
switch (test)
{
case '1':
_dbConnection = new SqlConnection("SQL Database", _timeOut);
_dbCommand = new DbCommand(_dbConnection, commandInput);
break;
case '2':
_dbConnection = new SqlConnection("SQL Database", _timeOut);
_dbCommand = new DbCommand(_dbConnection, null);
break;
case '3':
_dbConnection = new OracleConnection("Oracle Database", _timeOut);
_dbCommand = new DbCommand(_dbConnection, commandInput);
break;
case '4':
_dbConnection = new OracleConnection("Oracle Database", _timeOut);
_dbCommand = new DbCommand(_dbConnection, null);
break;
default:
return;
}
_dbCommand.ExecuteCommand();
Console.WriteLine("\nPress Enter to continue...");
Console.ReadLine();
}
}