addition of dates in database
hii.....am a beginner in c#.....
am havin a database to store set of dates n t dates should be distinct.
i hav not given t date column has primary key.. codin tat i hav given
below doesnt work properly....
can any one tell me wts wrong in it n how to add distinct dates
protected void Calendar1_SelectionChanged1(object sender, EventArgs e)
{
dap = new OleDbDataAdapter("select cdate from calen", con);
dap.Fill(ds1);
lbldate.Text = Calendar1.SelectedDate.ToShortDateString();
for (int i = 0; i <= (ds1.Tables[0].Rows.Count -1); i++)
{
if (ds1.Tables[0].Rows[i][0].ToString() == lbldate.Text)
{
lbldate.Text = "date already exists";
}
else
{
OleDbCommand com = new OleDbCommand();
com.CommandText = "insert into calen values('" + lbldate.Text + "')";
com.Connection = con;
com.ExecuteNonQuery();
break;
}
}
}