Format cell standard in Excel with c#


i have excel file enter in database. need read cells. problem type standard in excel. how convert standard type string when reading excel file using c#?

enter image description here

my code:

using (oledbconnection conn = new oledbconnection(sbconnection.tostring()))  {      var dt = new datatable();        string query = string.format("select  * [{0}]", sheetname);      conn.open();        oledbdataadapter adapter = new oledbdataadapter(query, conn);      adapter.fill(dt);        try      {          using (sqlconnection con = new sqlconnection(consstring))          {              con.open();                for (int = 2; < dt.rows.count; i++)              {                  for (int j = 1; j < dt.columns.count; j += 4)                  {                      try                      {                          string sourcestring = dt.rows[0][j].tostring();                            messagebox.show(sourcestring);                      }                  }             }          }      }  }

after compiling code :

enter image description here

perhaps should use dt.rows[i][j] instead of dt.rows[0][j].



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

wcf-sql adapter bug for operation on same table

Error connecting to Azure Blob using Shared Access signature