一、Oracle.ManagedDataAccess.dll连接数据库
首先需要下载Oracle.ManagedDataAccess.dll
我这里是采用了创建一个winform项目来进行演示
private void btn_start_Click(object sender, EventArgs e)
{
OracleConnection conn = null;
try
{
//获取与数据库的连接对象
conn = new OracleConnection();
//绑定连接字符串
conn.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=****.****.****.****)(PORT=****)) (CONNECT_DATA=(SERVICE_NAME=*****)));Persist Security Info=True;User ID=****;Password=*****;";
//开启连接
conn.Open();
//创建操作对象
OracleCommand cmd = conn.CreateCommand();
cmd.CommandText = "select * from yin_test";
cmd.CommandType = CommandType.Text;
//执行并设置返回值