国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 苍梧县| 蒲城县| 正定县| 亳州市| 河曲县| 毕节市| 辽源市| 会泽县| 汉中市| 古交市| 庆元县| 宁阳县| 鹿邑县| 理塘县| 西乡县| 浙江省| 山西省| 原阳县| 历史| 绵阳市| 河津市| 苍梧县| 威信县| 攀枝花市| 福建省| 安乡县| 南宁市| 海南省| 余庆县| 麦盖提县| 金华市| 冀州市| 廊坊市| 任丘市| 临桂县| 香港 | 隆安县| 青川县| 理塘县| 尼木县| 平原县|