新手问题,我用ODBC已经连上ORACLE了,现在想用asp.net通过ODBC连ORACLE,怎么连
我用ODBC已经连上ORACLE了,现在想用asp.net通过ODBC连ORACLE,怎么连,请高手帮忙解答。
[解决办法]
ding
[解决办法]
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();
[解决办法]
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();
[解决办法]
参看下面代码:
"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文件就可以了
具体代码
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();