sql - showing data from excel to datagridview using c# -


i'm using excel database, want show columns in datagridview using c#, problem have column formated hours (hh:mm) when want show data in datagridview column appears (30/12/1899 15:20) want 15:20 excel image

datagridview image code :

oledbdataadapter oda = new oledbdataadapter();                             datatable dt = new datatable();                             cmd.commandtext = "select inf, date,entrie, sortie,coupe,préparation,ford,eb,b7,qualité, production, logistique, ingenierie, maintenance, fournisseurs, administration, motifs, traitement, quantité, commentaire [" + sheetname + "] matricule =" + textbox4.text;                             cmd.connection = con;                             con.open();                             oda.selectcommand = cmd;                             oda.fill(dt);                             con.close();                             dt_all.merge(dt); 

after setting datatable data source datagridview set format column e.g.

datagridview1.columns["yourcolumnname"].defaultcellstyle.format = "hh:mm"; 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -