Oracle数据库连接

发表于:2007-06-22来源:作者:点击数: 标签:
odbc ew version: driver={microsoft odbc for oracle};server=oracleserver.world;uid=username;pwd=asdasd; old version: driver={microsoft odbc driver for oracle};connectstring=oracleserver.world;uid=myusername;pwd=mypassword; oledb, oledbconne

   

 

odbc





ew version:

driver={microsoft odbc for oracle};server=oracleserver.world;uid=username;pwd=asdasd;





old version:

driver={microsoft odbc driver for oracle};connectstring=oracleserver.world;uid=myusername;pwd=mypassword;





oledb, oledbconnection (.net)





tandard security:

rovider=msdaora;data source=myoracledb;user id=username;password=asdasd;

this ones from microsoft, the following are from oracle

tandard security:

rovider=oraoledb.oracle;data source=myoracledb;user id=username;password=asdasd;





trusted connection:

rovider=oraoledb.oracle;data source=myoracledb;osauthent=1;





oracleconnection (.net)





tandard:

data source=oracle8i;integrated security=yes;

this one works only with oracle 8i release 3 or later

declare the oracleconnection:



c#:

using system.data.oracleclient;

oracleconnection ooracleconn = new oracleconnection();

ooracleconn.connectionstring = my connectionstring;

ooracleconn.open();



vb.net:

imports system.data.oracleclient

dim ooracleconn as oracleconnection = new oracleconnection()

ooracleconn.connectionstring = my connectionstring

ooracleconn.open()





data shape





ms data shape:

rovider=msdatashape.1;persist security info=false;data provider=msdaora;data source=orac;user id=username;password=mypw









例子1:namespace oracle

{

///



/// webform1 的摘要说明。

///


ublic class webform1 : system.web.ui.page

{

rotected system.web.ui.webcontrols.datagrid datagrid1;

rivate dataset mydataset = new dataset();

rivate void page_load(object sender, system.eventargs e)

{

// 在此处放置用户代码以初始化页面

tring connstring=provider=oraoledb.oracle;data source=jtest;user id=system;password=manager;;

oledbconnection conn=new oledbconnection(connstring);

tring strcom = select * from system.lg_task_table;

conn.open();

oledbdataadapter mycommand = new oledbdataadapter(strcom,conn);

mycommand.fill(mydataset,system.lg_task_table);

datagrid1.datasource = mydataset.tables[system.lg_task_table].defaultview;

datagrid1.databind();

conn.close();



}



原文转自:http://www.ltesting.net