文件名称:C# 编程连接oracle数据库方法
文件大小:412KB
文件格式:RAR
更新时间:2016-04-04 00:45:30
C# oracle数据库
C# 编程连接oracle数据库方法 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.OleDb; using System.Data.OracleClient; namespace 连接测试 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { // string connString = "Provider=MSDAORA;data source=orcl;User Id=scott;Password=xyk03;"; textBox1.Text = "MSDAORA"; textBox2.Text = "orcl"; textBox3.Text = "scott"; textBox4.Text = "xyk03"; string connString = "Provider=" + textBox1.Text.ToString().Trim() + ";data source=" + textBox2.Text.ToString().Trim() + ";User Id=" + textBox3.Text.ToString().Trim() + ";Password=" + textBox4.Text.ToString().Trim() + ";"; OleDbConnection conn = new OleDbConnection(connString); OleDbCommand selcmd = new OleDbCommand(); selcmd.Connection = conn; selcmd.CommandText = "select * from emp where HIREDATE < to_date('1987-11-26','yyyy-mm-dd') "; OleDbDataAdapter da = new OleDbDataAdapter(); da.SelectCommand = selcmd; DataSet ds = new DataSet(); da.Fill(ds); textBox5.Text = ds.Tables[0].Compute("sum(SAL)", "true").ToString(); textBox6.Text = ds.Tables[0].Compute("Count(EMPNO)", "HIREDATE > '1983-11-26'").ToString(); }
【文件预览】:
连接数据库
----连接测试()
--------连接测试.suo(15KB)
--------连接测试()
--------连接测试.sln(925B)