日期:2014-05-18 浏览次数:20419 次
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();