国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

c#與oracle的連接!

2024-07-21 02:19:14
字體:
供稿:網(wǎng)友
using system.data.oledb;

新建一個(gè)類(用于數(shù)據(jù)庫連接的參數(shù)):

public static string getoracledbconnstr()
{
// 數(shù)據(jù)庫連接
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;
}

設(shè)置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.連接數(shù)據(jù)庫需要的參數(shù):

◎oledbconnection 用于建立連接

◎dataset 數(shù)據(jù)在內(nèi)存中的緩存,就是在內(nèi)存中建立一個(gè)與數(shù)據(jù)庫一致的表

◎oledbdataadapter 用于更新數(shù)據(jù)源

◎oledbcommand 用于執(zhí)行sql命令

2.連接完成后應(yīng)該馬上關(guān)閉連接。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 牟定县| 肇源县| 龙游县| 南通市| 运城市| 腾冲县| 荔浦县| 合山市| 正安县| 革吉县| 大姚县| 横峰县| 芜湖市| 葵青区| 康定县| 开化县| 南和县| 神农架林区| 卢湾区| 阜平县| 南汇区| 宝清县| 诏安县| 特克斯县| 句容市| 游戏| 扶余县| 岳西县| 桦川县| 公主岭市| 泰安市| 淳化县| 静安区| 苍山县| 绥化市| 明溪县| 伊川县| 岐山县| 华蓥市| 香河县| 鸡西市|