Click here to Skip to main content
16,015,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
As our application is going to deploy in Azure Environment as PAAS...hence we can not install any driver . Looking for any substitute which can able to load data set in grid with out using OLEDB Driver .My Application is 4.8 dot net framework based app.

Existing Code
===============
C#
   /// <summary>
   /// Return dataset representing attached excel file
   /// </summary>
   /// <param name="ds" />
   /// <returns>
   public DataSet FillDataSet(DataSet ds,int rows_to_ignore)
{
  int max_empty_allowed = 2;
  if (ds == null)
    ds = new DataSet();
  DataSet _tmpds = new DataSet();      
  this._dc = new System.Data.OleDb.OleDbConnection(this.Connection);      
  this._dcomm = new System.Data.OleDb.OleDbCommand();
  this._dcomm.Connection = this._dc;
  this._dcomm.CommandText = this.CommandText;
  this._adapter = new System.Data.OleDb.OleDbDataAdapter(this._dcomm);
  try
  {
    this._adapter.Fill(ds);
    if (ds.Tables.Count == 0)
      return ds;
    if (rows_to_ignore > 0)
    {
      while(rows_to_ignore > 0)
      {
        ds.Tables[0].Rows[0].Delete();
        rows_to_ignore--;
      }
      ds.Tables[0].AcceptChanges();
    }
    _tmpds = ds.Clone();
    ///Ignore empty rows
    int empty_row = 0;
    foreach(DataRow _dr in ds.Tables[0].Rows)
    {
      int emptyCount = 0;
      foreach(DataColumn _dc in ds.Tables[0].Columns)
      {
        if (_dr[_dc] == DBNull.Value)
          emptyCount++;            
      }
      if (emptyCount != ds.Tables[0].Columns.Count)
        _tmpds.Tables[0].ImportRow(_dr);
      else
      {
        empty_row++;
        /// Reached empty allowed count ignore rest of excel sheet
        if (empty_row >= max_empty_allowed)
          break;
      }
    }        
    this._dc.Dispose();
    return _tmpds;
  }
  catch(System.Data.OleDb.OleDbException oex)
  {
    throw oex;
  }
}


What I have tried:

Looking for any substitute which can work in PAAS
Posted
Updated 10-Jul-24 19:44pm
v2

1 solution

I know this library is available as net462, netstandard2.0 and netstandard2.1, so you should be able to install this free NuGet package[^] and work with it. You can find details of working with this package in the documentation here[^].
 
Share this answer
 
Comments
Thirumadhi T Johnson 11-Jul-24 2:05am    
Hi Pete Thanks for response ..can you please explain more elaborately.. for the above existing code which one should I use . It would be great help . Looking forwards for your reply :)
Pete O'Hanlon 11-Jul-24 2:25am    
The Github page I linked to has practical examples of using the NuGet implementation. Simply import the package, and follow the documentation to craft the result you need.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900