本文共 938 字,大约阅读时间需要 3 分钟。
// ODBC DSN using System.Data.Odbc; OdbcConnection conn = new OdbcConnection(); conn.ConnectionString = "Dsn=DsnName;" + "Uid=UserName;" + "Pwd=Secret;"; conn.Open();
// ODBC without DSN using System.Data.Odbc; OdbcConnection conn = new OdbcConnection(); conn.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};" + "Driverid=790;" + "Dbq=C:/MyPath/SpreadSheet.xls;" + "DefaultDir=C:/MyPath;"; conn.Open();
// OleDb with MS Jet using System.Data.OleDb; OleDbConnection conn = new OleDbConnection(); conn.ConnectionString = "Driver=Microsoft.Jet.OLEDB.4.0;" + "Data Source=C:/MyPath/SpreadSheet.xls;" + @"Extended Properties=""Excel 8.0;HDR=Yes"""; conn.Open();
转载地址:http://qotqj.baihongyu.com/