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

首頁(yè) > 編程 > .NET > 正文

oracle9i連接asp.net方法及注意點(diǎn)

2024-07-10 12:56:23
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友


#region 聲明
//----------------------------------------------------------------------
//
// 修改: 李淼(nick.lee)
//
// oracle9i連接asp.net方法及注意點(diǎn)

// 時(shí)間:2005-3-18

// [email protected]
// qq:16503096
//注意:引用請(qǐng)標(biāo)明修改出處,謝謝
//----------------------------------------------------------------------
#endregion

推薦方式

public void oledboracle_dataset()
{
string connectionstring="data source=mine;user=sys;password=sys;"; //寫(xiě)連接串
oracleconnection conn=new oracleconnection(connectionstring); //創(chuàng)建一個(gè)新連接
oraclecommand cmd= new oraclecommand("select * from fjdl.t_rights",conn);
dataset ds = new dataset();
oracledataadapter oda=new oracledataadapter();
oda.selectcommand=cmd;
oda.fill(ds);
conn.close();
datagrid1.datasource=ds.tables[0].defaultview;
datagrid1.databind();
}

以下為用dataset和datareader,oledb和oralceclient的四種方法

public void oledboracle_datareader()
{
system.data.oledb.oledbconnection oledb1=new system.data.oledb.oledbconnection();
string sqltext="select * from scott.tadmin";
system.data.oledb.oledbdatareader reader;

oledb1.connectionstring="provider=/"oraoledb.oracle.1/";user id=system;password=system;data source=rick;";
system.data.oledb.oledbcommand com=new system.data.oledb.oledbcommand(sqltext,oledb1);

com.connection.open();
reader=com.executereader();

datagrid1.datasource=reader;
datagrid1.databind();

//this.response.write(oledbconnection1.connectionstring);
reader.close();
com.connection.close();
}
public void oledboracle_dataset()
{
system.data.oledb.oledbconnection oledb1=new system.data.oledb.oledbconnection("provider=/"oraoledb.oracle.1/";user id=system;password=system;data source=rick;");
string sqltext="select * from scott.tadmin";
system.data.dataset set1=new dataset();
system.data.oledb.oledbdataadapter ada1=new system.data.oledb.oledbdataadapter (sqltext,oledb1);
ada1.fill(set1,"data1");

this.datagrid2.datasource=set1.tables["data1"].defaultview;
this.datagrid2.databind();
}
public void oracle_dataset()
{
system.data.oracleclient.oracleconnection oracle1=new system.data.oracleclient.oracleconnection("user id=system;data source=rick;password=system");
string sqltext="select * from scott.tadmin";
system.data.dataset set1=new dataset();
system.data.oracleclient.oracledataadapter ada1=new system.data.oracleclient.oracledataadapter(sqltext,oracle1);
ada1.fill(set1,"oracle_data1");

this.datagrid3.datasource=set1.tables["oracle_data1"].defaultview;
this.datagrid3.databind();
}
public void oracle_datareader()
{
system.data.oracleclient.oracleconnection oracle2=new system.data.oracleclient.oracleconnection();
string sqltext="select * from scott.tadmin";
system.data.oracleclient.oracledatareader reader;

oracle2.connectionstring="user id=system;user id=system;data source=rick;password=system";
system.data.oracleclient.oraclecommand com=new system.data.oracleclient.oraclecommand(sqltext,oracle2);

com.connection.open();
reader=com.executereader();

datagrid4.datasource=reader;
datagrid4.databind();

//this.response.write(oledbconnection1.connectionstring);
reader.close();
com.connection.close();
}

注意點(diǎn):

如果不設(shè)置遠(yuǎn)程數(shù)據(jù)的本級(jí)網(wǎng)絡(luò)配置

ora-00162: external dbid length 18 is greater than maximum (16)

連接名稱(chēng)不能超過(guò)16個(gè)字符

修改方法

configuration and migration tools->net configuration assistant中配置



發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 满洲里市| 德钦县| 谢通门县| 崇礼县| 广河县| 顺义区| 阿图什市| 逊克县| 航空| 连平县| 彭泽县| 安西县| 东港市| 河池市| 都匀市| 金秀| 黔东| 岗巴县| 昆明市| 礼泉县| 哈巴河县| 高陵县| 五常市| 霍林郭勒市| 文化| 绥化市| 两当县| 璧山县| 团风县| 紫金县| 顺义区| 海阳市| 沿河| 乡宁县| 西充县| 祁连县| 安宁市| 邵阳市| 古田县| 丹东市| 梁平县|