I am new to C#, and learning. I have a SQL Server database where I have table record
that has a column dob
of data type date
. I am trying to insert into dob
from my textbox which has a value of 19-08-17
with the following code
datebox.Text = "19-08-17";
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand com = new SqlCommand(query, con);
string query= "insert into record (dob) values(@db)";
com.Parameters.AddWithValue("@db", datebox.Text);
com.ExecuteNonQuery();
But I get this error
Conversion failed when converting date and/or time from character string.
How can I solve this?