9,不检索数据
代码:
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=shibei;Password=nsic;Unicode=True");
thisConnection.Open();//此处可以不用打开
OracleCommand thisCommand = thisConnection.CreateCommand();
thisCommand.CommandText = "update N_AIT set NAME = '改你了,怎么地' where ID = 34251";
int rows = 0;
try
{
rows = thisCommand.ExecuteNonQuery();//返回行数
//取出返回值
Console.WriteLine(Convert.ToString(rows));
}
catch (Exception er)
{
string merr = "err:" + er.ToString();
Console.WriteLine(merr);
}
finally
{
thisConnection.Close();
thisConnection.Dispose();//释放所有资源
thisCommand.Parameters.Clear();
thisCommand.Dispose();//释放所有资源
}
}
}
}
运行结果:
注意:此方法对删除和插入同样有效哦