title: Retrieving data from xlsx using OleDb(C#), how to get the count of lines in the xlsx?
body: <p>My final goal is to retrieve the data from .xlsx file and load them into .mdb (Microsoft Access) file. My code is now like this:</p>
  
  <pre><code>    String fileName = "1.xlsx";
      OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + fileName + ";" + ";Extended Properties=\"Excel 12.0;HDR=YES;IMEX=1\"");
      conn.Open();
      DataTable dtSheetName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
      string cmdText = "SELECT * FROM [sheet1$A3:B3]";
      DataSet ds;
      using (OleDbCommand cmd = new OleDbCommand(cmdText))
      {
          cmd.Connection = conn;
          OleDbDataAdapter adpt = new OleDbDataAdapter(cmd);
          ds = new DataSet();
          adpt.Fill(ds, "sheet1");
      }
  </code></pre>
  
  <p>But this is when I know how many lines are there in the sheet. What if I don't know about this information? Can I somehow manage to know how many lines are there in the sheet?</p>