使用日期时间选择器将日期插入数据库

This is my first time working with date time picker in c#.
This is my insert data user control.It adds all the data present in all the textboxes to DB.Neglect the order date and call date both are not functional.

The data type of the all the current date in DB is 'date'.
When I run the program and insert and click the txtbox of current date ,it is autofilled with today's date [as programmed] but it is inserted in such format 'dd/mm/yyyy' But earlier when i used to manually enter date in the textbox the format would be 'yyyy-mm-dd'. Earlier It used to Insert the data into DB but now it doesn't.
I guess that is because of the format of the date and i am missing something in my code:

private bool insertdata()
        {
           //I've included the value of current date text box in string format which I think may be causing problem 
                string custname = txtcustname.Text, custcat = cmbcustcat.Text, date = txtdate.Text, phoneno = txtphoneno.Text, dresstype = cmbtype.Text, pattern = cmbpattern.Text, height = txtheight.Text, waist = txtwaist.Text, padar = txtpadar.Text, advance = txtadvance.Text;
                if (custname != null && custcat != null && date != null && phoneno != null && dresstype != null && pattern != null && height != null && waist != null && padar != null)
                {
                    cmd = new SqlCommand("INSERT INTO ordertbl(cust_name,cust_cat,date,phoneno,dress_type,pattern,height,waist,padar,adv) VALUES('" + custname + "','" + custcat + "','" + date + "','" + phoneno + "','" + dresstype + "','" + pattern + "','" + height + "','" + waist + "','" + padar + "','" + advance + "')", con);
                    cmd.ExecuteNonQuery();
                    return true;
                }
                else 
                {
                    return false;
                }
           //this method is called in the add data button


        }
        private void calenderdate(TextBox txtbox)
        {
            //autofills textbox with current date...The drop down arrow beside the txtbox is the DTP and it is initially not visible.
            if (calcurrentdate.Visible == false)
            {
                calcurrentdate.Visible = true;
                txtbox.Text = calcurrentdate.Value.ToShortDateString();
            }
        }
private void txtdate_Click(object sender, EventArgs e)
        {
            //when the text box of currentdate is clicked it is auto filled with today's date
            calenderdate(txtdate);
        } 
评论