当前位置: 代码迷 >> ASP.NET >> 新手有关问题,小弟我用ODBC已经连上ORACLE了,现在想用asp.net通过ODBC连ORACLE,如何连
  详细解决方案

新手有关问题,小弟我用ODBC已经连上ORACLE了,现在想用asp.net通过ODBC连ORACLE,如何连

热度:9588   发布时间:2013-02-25 00:00:00.0
新手问题,我用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();
  相关解决方案