有什么帮助我在这里做错了吗?如果我试图读取示例 TestCaseName 的唯一行,case_1
那么我将获取不同行的数据。
我怎样才能确保它只阅读被要求阅读的内容?我正在使用 where 子句,但似乎没有过滤它。
string connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", EXCELFILENAME);
string testCaseName = "case_1
string query = String.Format("SELECT * from [{0}$] WHERE TestCaseName=\"{1}\"", workbookName, testCaseName);
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, connectionString);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
DataTable myTable = dataSet.Tables[0];
TestCaseName Name Active Status etc...
----------------------------------------------------------------
case_1 Tom yes Completed etc...
----------------------------------------------------------------
case_2 John yes etc...
----------------------------------------------------------------
case_3 Jim yes etc...
----------------------------------------------------------------
case_4 Don yes etc...
----------------------------------------------------------------
case_5 Sam yes Visitor etc...
----------------------------------------------------------------