日期:2014-05-18  浏览次数:20419 次

新手问题,我用ODBC已经连上ORACLE了,现在想用asp.net通过ODBC连ORACLE,怎么连
我用ODBC已经连上ORACLE了,现在想用asp.net通过ODBC连ORACLE,怎么连,请高手帮忙解答。

------解决方案--------------------
ding
------解决方案--------------------
C# code
string connstr = "Data Source=orcl;User Id=system;Password=xxx;";
OracleConnection conn = new OracleConnection(connstr);
conn.Open();
OracleDataAdapter oda = new OracleDataAdapter("select * from test",conn);
DataTable dt = new DataTable();
oda.Fill(dt);
DataList1.DataSource = dt;
DataBind();
conn.Close();

------解决方案--------------------
C# code
string connstr = "DSN=mydsn";
OdbcConnection conn = new OdbcConnection(connstr);
conn.Open();
OdbcDataAdapter oda = new OdbcDataAdapter("select * from test", conn);
DataTable dt = new DataTable();
oda.Fill(dt);
DataList1.DataSource = dt;
DataBind();
conn.Close();

------解决方案--------------------
参看下面代码:

C# code
"Driver={SQL Server};Server=(local);Trusted_Connection=Yes;Database=AdventureWorks;"

"Driver={Microsoft ODBC for Oracle};Server=ORACLE8i7;Persist Security Info=False;Trusted_Connection=Yes"

"Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\bin\Northwind.mdb"

"Driver={Microsoft Excel Driver (*.xls)};DBQ=c:\bin\book1.xls"

"Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=c:\bin"

"DSN=dsnname"

------解决方案--------------------
下载一个dll文件就可以了
具体代码
C# code
string connstr = "Data Source=orcl;User Id=system;Password=xxx;";
OracleConnection conn = new OracleConnection(connstr);
conn.Open();
OracleDataAdapter oda = new OracleDataAdapter("select * from test",conn);
DataTable dt = new DataTable();
oda.Fill(dt);
DataList1.DataSource = dt;
DataBind();
conn.Close();