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.
Wil YoumansPosted Apr 11, 2011, 8:42 AM
jinith josephPosted Apr 11, 2011, 3:18 AM
IFormatProvider theCultureInfo = new System.Globalization.CultureInfo("en-GB", true);DateTime theDateTime = DateTime.ParseExact(abc, "mm-dd-yyyy", theCultureInfo);
Hope this helps..