8,直接执行SQL命令
程序:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data; //注意
using System.Data.OracleClient; //Oracle数据库
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
OracleConnection thisConnection = new OracleConnection(@"Data Source=orcl;User ID=system;Password=myoracle;Unicode=True");
thisConnection.Open();//此处可以不用打开
OracleCommand thisCommand = thisConnection.CreateCommand();
thisCommand.CommandText = "select count(*) from Histalamt";
Object countResult = thisCommand.ExecuteOracleScalar();
Console.WriteLine("Count = {0}", countResult);
thisConnection.Close();
Console.ReadKey();
}
}
}
运行结果: