shobitha 0 Newbie Poster

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;
                }
            }
            
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.