Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Error - No Data Exists for the row/column

$
0
0

Hi

  ON below line i get above error

string m_DocNo = dr[0].ToString();

void Upload_InternetData()
        {
            OleDbConnection connection = new OleDbConnection();
            try
            {
                string path = Server.MapPath("~") + "/UpLoad/Data.xls";
                string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\";";
                connection.ConnectionString = excelConnectionString;
                OleDbCommand command = new OleDbCommand("select * from [Sheet1$]", connection);
                connection.Open();
                DbDataReader dr = command.ExecuteReader();
                if (dr.HasRows)
                {
                    string m_DocNo = dr[0].ToString();
                }
                dr.Close();

            }
            catch (Exception ex)
            {
            }
        }

Thanks


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>