1
string OLEDBConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0;";
2
string resourcePath = Application.StartupPath;
3
resourcePath = resourcePath.Replace(@"bin\Debug",@"resource\");
4
resourcePath += "文件多名称.xls";
5
OLEDBConnStr = string .Format(OLEDBConnStr,resourcePath);
6
string strCreateTableSQL = "select count(*) from [工作区名称$]";
7
OleDbConnection oConn = new OleDbConnection();
8
9
oConn.ConnectionString = OLEDBConnStr;
10
OleDbCommand oCreateComm = new OleDbCommand();
11
oCreateComm.Connection = oConn;
12
oCreateComm.CommandText = strCreateTableSQL;
13
14
oConn.Open();
15
object count = oCreateComm.ExecuteScalar();
16
oConn.Close();
string OLEDBConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0;";2
string resourcePath = Application.StartupPath;3
resourcePath = resourcePath.Replace(@"bin\Debug",@"resource\");4
resourcePath += "文件多名称.xls";5
OLEDBConnStr = string .Format(OLEDBConnStr,resourcePath);6
string strCreateTableSQL = "select count(*) from [工作区名称$]";7
OleDbConnection oConn = new OleDbConnection(); 8
9
oConn.ConnectionString = OLEDBConnStr; 10
OleDbCommand oCreateComm = new OleDbCommand();11
oCreateComm.Connection = oConn;12
oCreateComm.CommandText = strCreateTableSQL;13

14
oConn.Open(); 15
object count = oCreateComm.ExecuteScalar();16
oConn.Close();
浙公网安备 33010602011771号