note it is windows application
Save Code as follows;
try
{
sql = "insert into Tb_Declared_Holidays ([Holiday],[Reason] " + "values('" + txt_date.Text + "','" + txt_reason.Text + "')";
GFun.Error = "";
GFun.InsertAccessData(sql);
if (GFun.Error.ToString() != "")
{
MessageBox.Show(GFun.Error.ToString(), "Error");
this.Cursor = Cursors.Arrow;
}
MessageBox.Show("Record inserted successfully", "Records Inserted", MessageBoxButtons.OK, MessageBoxIcon.Information);
LoadDeclarHolidayDetails();
GFun.OleDbCon.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Cursor = Cursors.Arrow;
}
when i click the save button and record saved in the database.
Database records as follows;
Holiday Reason
1/14/2013 Leave
//checking Date is already exists or not
DateTime holidaydate = Convert.ToDateTime(txt_date.Text);
sql = "select * from Tb_Declared_Holidays where Holiday = '" + holidaydate + "'";
oledr = GFun.ReadAcessSql(sql);
oledr.Read();
if (oledr.HasRows == true)
{
MessageBox.Show("Selected Date is already exists,Choose Different Date", "Date Exists", MessageBoxButtons.OK, MessageBoxIcon.Information);
Btn_Calendar.Focus();
return;
}
when i click the save button error shows as follows;
string was not recognized a valid datetime.
from my above code what is the problem.
note it is windows application