Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > .NET > C#.NET > c#与oracle的连接!
【标  题】:c#与oracle的连接!
【关键字】:oracle,c,连接,oracle
【来  源】:csdn.net

c#与oracle的连接!

Your Ad Here using System.Data.OleDb; 新建一个类(用于数据库连接的参数): public static string GetOracleDbConnStr() { // 数据库连接 string tempUser="system",tempPassword="andystarmkmk",tempDataSource="andy"; string tempstrCon="Provider=OraOLEDB.Oracle.1;Persist Security Info=False;"+ "User ID="+tempUser+";Password="+tempPassword+";Data Source="+tempDataSource; return tempstrCon; } 设置Click事件: private void button1_Click(object sender, System.EventArgs e) { string strSQL="select * from scott.aa"; string tempstrCon=Form1.GetOracleDbConnStr(); string tempstrCom="select * from scott.aa"; OleDbConnection tempmyConn=new OleDbConnection(tempstrCon); DataSet tempmyDataSet=new DataSet(); OleDbDataAdapter tempmyCommand=new OleDbDataAdapter (tempstrCom,tempmyConn); tempmyCommand.Fill(tempmyDataSet); tempmyConn.Open(); dataGrid1.DataSource =tempmyDataSet; OleDbCommand tempCommand=new OleDbCommand(strSQL,tempmyConn); tempCommand.ExecuteNonQuery(); tempmyConn.Close(); } 注意: 1.连接数据库需要的参数: ◎OleDbConnection 用于建立连接 ◎DataSet 数据在内存中的缓存,就是在内存中建立一个与数据库一致的表 ◎OleDbDataAdapter 用于更新数据源 ◎OleDbCommand 用于执行SQL命令 2.连接完成后应该马上关闭连接。
用C#建立自己的Web服务器:【上一篇】
.NET客户端应用程序:.NET应用程序更新组件(1):【下一篇】
【相关文章】
没有相关文章
【随机文章】
  • 新手kernel2.6.0编译升级方法
  • 1tie.cn网站分析
  • ifconfig简介
  • 《魔高一丈2.0》开发实例
  • Web服务器大扫除_目录
  • 新版源码安装配置使用Postgresql8.1.3+PostGIS1.1.2
  • 命令集锦,丰富你的知识
  • showModelessDiablog()的参数回调,以及父级页面元素引用的方法
  • DHCP学习记录
  • 浅析应用服务器
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.