0

In sql the date column is =01.10.2017(startingdate) and i am getting this date to datagridview1. But datagridview showing this date as 1.10.2017. I can't find my mistake.

This is the I code I'm using:

public void veri_getir(string veriler)
{
    SqlDataAdapter da = new SqlDataAdapter(veriler, con);
    DataSet ds = new DataSet();
    da.Fill(ds);

    dataGridView2.DataSource = ds.Tables[0];
}

veri_getir("Select startingdate from datetable");
sambomartin
  • 6,663
  • 7
  • 40
  • 64
  • So you dont like the date format? its missing leading zeros? – BugFinder Nov 07 '17 at 08:18
  • Yes its missing leading zeros @BugFinder –  Nov 07 '17 at 08:19
  • You will have to format the DateTime string when binding to gridview – Prateek Shrivastava Nov 07 '17 at 08:21
  • Shame you didnt even try googling it @ismailAlgün theres many good full examples out there, including a doc from microsoft [https://learn.microsoft.com/en-us/dotnet/framework/winforms/controls/how-to-format-data-in-the-windows-forms-datagridview-control](here) and stuff here on stackoverflow – BugFinder Nov 07 '17 at 08:26
  • How @PrateekShrivastava –  Nov 07 '17 at 08:58
  • thanks to everyone i solve problem with this code dataGridView2.Columns["startingdate"].DefaultCellStyle.Format = "dd.MM.yyyy"; –  Nov 07 '17 at 10:40

0 Answers0