C#连接Oracle 字符串
来源:互联网 发布:阿瓦隆之王兵营数据 编辑:程序博客网 时间:2024/04/27 23:05
注:using System.Data.OracleClient; 需要在项目右键点击,选择 '添加引用' ,在 .NET 中选择该项..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OracleClient;
namespace Appneu
{
public partial class FrmCnfTable : Form
{
public FrmCnfTable()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
#region 从region到endregion是手工写的。别的都是系统自动生成的
string constring = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.3.120) (PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)));Persist Security Info=True;User Id=wangjj; Password=wangjj";
OracleConnection conn = new OracleConnection(constring);//进行连接
try
{
conn.Open();//打开指定的连接
OracleCommand com = conn.CreateCommand();
com.CommandText = "Select Sysdate From dual ";//写好想执行的Sql语句
OracleDataReader odr = com.ExecuteReader();
while (odr.Read())//读取数据,如果返回为false的话,就说明到记录集的尾部了
{
label1.Text = "远程数据库时间:"+odr.GetOracleDateTime(0).ToString();//获得远程数据库时间
}
odr.Close();//关闭reader.这是一定要写的
}
catch
{
MessageBox.Show("erro");//如果发生异常,则提示出错
}
finally
{
conn.Close();//关闭打开的连接
}
#endregion
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OracleClient;
namespace Appneu
{
public partial class FrmCnfTable : Form
{
public FrmCnfTable()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
#region 从region到endregion是手工写的。别的都是系统自动生成的
string constring = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.3.120) (PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)));Persist Security Info=True;User Id=wangjj; Password=wangjj";
OracleConnection conn = new OracleConnection(constring);//进行连接
try
{
conn.Open();//打开指定的连接
OracleCommand com = conn.CreateCommand();
com.CommandText = "Select Sysdate From dual ";//写好想执行的Sql语句
OracleDataReader odr = com.ExecuteReader();
while (odr.Read())//读取数据,如果返回为false的话,就说明到记录集的尾部了
{
label1.Text = "远程数据库时间:"+odr.GetOracleDateTime(0).ToString();//获得远程数据库时间
}
odr.Close();//关闭reader.这是一定要写的
}
catch
{
MessageBox.Show("erro");//如果发生异常,则提示出错
}
finally
{
conn.Close();//关闭打开的连接
}
#endregion
}
}
}
- C#连接Oracle 字符串
- c# 连接oracle数据库字符串
- C#的oracle连接字符串
- C#连接Oracle数据库的连接字符串
- C#连接Oracle数据库的连接字符串
- c#连接oracle的连接字符串定义
- c#连接oracle数据库的字符串
- C#连接Oracle数据库的字符串
- c# 连接远程oracle 数据库 字符串
- C#连接Oracle数据库的字符串
- C#连接Oracle数据库的字符串
- ODBC连接Oracle 9i, C#连接字符串
- C#连接SQLServer2005与Oracle的连接字符串
- C#连接Oracle数据库字符串【51cto在线经典书籍】
- C#连接远程oracle字符串,返回操作时间代码
- oracle 11G client 连接 oracle 10G 数据库时 C#中配置的连接字符串
- C#连接字符串收集
- C#连接SQLite字符串
- 017 重新设计后,功能增强了
- 空白的贺年卡
- 疑惑:如何用hql语句查询前10条数据??求解!!!
- 新的开始
- ubuntun下实现了dnw2的usb文件传输
- C#连接Oracle 字符串
- JDBC的CRUD操作中使用模板模式
- SSH:使用事务和不使用事务的区别
- C语言平面几何5-两点确定一条直线
- C语言实现一维小波变换
- JDBC的CRUD操作中使用策略模式
- Linux下安装Apache PHP MYSQL
- 黑客常用工具介绍
- css学习笔记(基础篇)