Wil Youmans

Wil Youmans

  • NA
  • 25
  • 0

DateTime in db only shows date w/ time of zero

Apr 10 2011 9:27 PM
Hi,
My database with datetime fields only display the date?

This is an untyped dataset and if I go back after the insert and edit it, then it displays the time as well.

This is the insert statement:

private void btnInsert_Click(object sender, EventArgs e)

{

try

{

DataRow drCurrent = GetRow();

dataGridView1.Visible = false;

this.Validate();

clientTimesBindingSource.EndEdit();

int tbid = (int)drCurrent["TableID"];

DateTime time1 = (DateTime)drCurrent["Time In"];

DateTime time2 = (DateTime)drCurrent["Time Out"];


this.clientTimesTableAdapter.Insert((int)cbFullNames.SelectedValue, time1, time2);


MessageBox.Show("Update successful");


}

catch (System.Exception ex)

{

MessageBox.Show("Update failed:\n" + ex.ToString());


}

finally

{

dataGridView1.Visible = true;

dataGridView1.Refresh();

}

}


This updates the db but the DateTime fields all have a time of 0.00.xxxx unless I update them again too.

Answers (2)