Dim startdate1 As String = DateTimePicker1.Value.Date
            Dim enddate As String = DateTimePicker2.Value.Date

            myConnection = New SqlConnection(connectionstring)

                Dim insert As SqlCommand = New SqlCommand(" INSERT INTO Client_Details (Contract_Name ,Client_Name  ,VAT_No ,Cilent_Address,Start_Date,End_Date ,Contract_Value,Telephone_No) VALUES('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox3.Text & "','" & startdate1 & "','" & enddate & "','" & TextBox7.Text & "')", myConnection)
                MessageBox.Show("New Project  detail is Added")

when use this coding to insert a date value I got the error below.
"conversion failed when converting datetime from string"
I used sql 2005 & vb.net 2008

Try this directly into your query:

Substitute DateValue(DateTimePicker1.Value.Date) in place of startdate1 in SQL Query, and DateValue(DateTimePicker2.Value.Date) in place of enddate.

You can't tell what's wrong with a query unless you can see the query. After you create it do


and post the results here.

This question has already been answered. Start a new discussion instead.