日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > C# >内容正文

C#

oracle ado6,c# ado 连接数据库 六步曲

發布時間:2025/3/12 C# 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle ado6,c# ado 连接数据库 六步曲 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

建立連接分為六步:

1.定義連接字符串,oracle 的連接字符串為:

private?static?string?connString?=?"Data?Source=192.168.1.130:1521/mydata;Persist?Security?Info=True;User?ID=em_test;Password=test123;Unicode=True";

2.根據連接字符串成連接

3.打開連接

4.實例命令對象

5.操作

6.關閉連接

看一個例子:

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?OpenCloseDB

{

public?partial?class?Form1?:?Form

{

public?Form1()

{

InitializeComponent();

}

private?void?button1_Click(object?sender,?EventArgs?e)

{

OracleConnection?connection?=?null;

int?num?=?0;

string?message?=?"";

String?sql?=?"select?count(*)?from?ex_user";

try

{

string?connString?=?"Data?Source=mydata;Persist?Security?Info=True;User?ID=test;Password=huikk123;Unicode=True";

//?創建connection對象

connection?=?new?OracleConnection(connString);

//?打開連接

connection.Open();

OracleCommand?command?=?new?OracleCommand(sql,?connection);

num?=?int.Parse(command.ExecuteScalar().ToString());

message?=?string.Format("共有{0}條用戶信息!",?num);

MessageBox.Show(message);

}

catch?(Exception?ex)

{

MessageBox.Show("出現異常"+ex.Message);

}

finally

{

if?(connection?!=?null)

{

connection.Close();

}

}

}

}

}

原文:http://www.cnblogs.com/gc2013/p/3860809.html

總結

以上是生活随笔為你收集整理的oracle ado6,c# ado 连接数据库 六步曲的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。