11C#讀取轉換Excel檔案的優化(源代碼)                    "Data Source=" + this.tBFileAddress.Text.Trim() + ";" +
 12C#讀取轉換Excel檔案的優化(源代碼)                    "Extended Properties='Excel 8.0;HDR=YES;IMEX=1;'";
 13C#讀取轉換Excel檔案的優化(源代碼)
 14C#讀取轉換Excel檔案的優化(源代碼)                // Create connection object by using the preceding connection string.
 15C#讀取轉換Excel檔案的優化(源代碼)                OleDbConnection objConn = new OleDbConnection(sConnectionString);
 16C#讀取轉換Excel檔案的優化(源代碼)
 17C#讀取轉換Excel檔案的優化(源代碼)                // Open connection with the database.
 18C#讀取轉換Excel檔案的優化(源代碼)                objConn.Open();
 19C#讀取轉換Excel檔案的優化(源代碼)
 20C#讀取轉換Excel檔案的優化(源代碼)                // The code to follow uses a SQL SELECT command to display the data from the worksheet.
 21C#讀取轉換Excel檔案的優化(源代碼)
 22C#讀取轉換Excel檔案的優化(源代碼)                // Create new OleDbCommand to return data from worksheet.
 23C#讀取轉換Excel檔案的優化(源代碼)                OleDbCommand objCmdSelect =new OleDbCommand("SELECT * FROM ["+tBsheet.Text.Trim()+"$] where 料號<>''", objConn);
 24C#讀取轉換Excel檔案的優化(源代碼)
 25C#讀取轉換Excel檔案的優化(源代碼)                // Create new OleDbDataAdapter that is used to build a DataSet
 26C#讀取轉換Excel檔案的優化(源代碼)                // based on the preceding SQL SELECT statement.
 27C#讀取轉換Excel檔案的優化(源代碼)                OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
 28C#讀取轉換Excel檔案的優化(源代碼)
 29C#讀取轉換Excel檔案的優化(源代碼)                // Pass the Select command to the adapter.
 30C#讀取轉換Excel檔案的優化(源代碼)                objAdapter1.SelectCommand = objCmdSelect;
 31C#讀取轉換Excel檔案的優化(源代碼)
 32C#讀取轉換Excel檔案的優化(源代碼)                // Create new DataSet to hold information from the worksheet.
 33C#讀取轉換Excel檔案的優化(源代碼)                DataSet objDataset1 = new DataSet();
 34C#讀取轉換Excel檔案的優化(源代碼)
 35C#讀取轉換Excel檔案的優化(源代碼)                // Fill the DataSet with the information from the worksheet.
 36C#讀取轉換Excel檔案的優化(源代碼)                objAdapter1.Fill(objDataset1,"料號基本資料");
 37C#讀取轉換Excel檔案的優化(源代碼)
 38C#讀取轉換Excel檔案的優化(源代碼)                Thread.Sleep(200);
 39C#讀取轉換Excel檔案的優化(源代碼)                statusBarPanel4.Text="正在讀取數據C#讀取轉換Excel檔案的優化(源代碼)["+objDataset1.Tables["料號基本資料"].Rows.Count+"]";
 40C#讀取轉換Excel檔案的優化(源代碼)                Thread.Sleep(500);
 41C#讀取轉換Excel檔案的優化(源代碼)                // Clean up objects.
 42C#讀取轉換Excel檔案的優化(源代碼)                objConn.Close();
 43C#讀取轉換Excel檔案的優化(源代碼)
 44C#讀取轉換Excel檔案的優化(源代碼)                dtbSearch=objDataset1.Tables["料號基本資料"];
 45C#讀取轉換Excel檔案的優化(源代碼)
 46C#讀取轉換Excel檔案的優化(源代碼)                progressBar1.Value=30;
 47C#讀取轉換Excel檔案的優化(源代碼)
 48C#讀取轉換Excel檔案的優化(源代碼)            }
 49C#讀取轉換Excel檔案的優化(源代碼)            catch
 50        }

測試PASS!

相关文章:

  • 2022-12-23
  • 2022-02-20
  • 2022-12-23
  • 2021-09-17
  • 2021-07-17
  • 2021-06-10
  • 2021-11-18
  • 2022-12-23
猜你喜欢
  • 2021-09-30
  • 2021-12-17
  • 2021-06-07
  • 2022-12-23
  • 2022-02-03
  • 2022-02-10
  • 2022-12-23
相关资源
相似解决方案