日期:2014-05-18 浏览次数:20523 次
public DataTable QueryDataTable(string sql) { DataTable dt = new DataTable(); using ( OdbcConnection dbconn = new OdbcConnection(ConfigurationManager.ConnectionStrings["ODBCConnectionString"].ConnectionString)) { OdbcDataAdapter DataAdapter = new OdbcDataAdapter(sql, dbconn); DataAdapter.Fill(dt); } return dt; }
//连接串错了 //for access cn= new OdbcConnection("Driver={Microsoft Access Driver (*.mdb)}; DBQ=D:\\Program Files\\Microsoft Office\\Office10\\Samples\\Northwind.mdb;UID=;PWD=;"); //for SQL server cn= new OdbcConnection("Driver={SQL Server};Server=mySQLServer;UID=sa; PWD=myPassword;Database=Northwind;"); //for Oracle cn= new OdbcConnection("Driver={Microsoft ODBC for Oracle};Server=myOracleServer; UID=demo;PWD=demo;"); //for dsn cn= new OdbcConnection("dsn=myDSN;UID=myUid;PWD=myPwd;");