I want to insert Only date in databse..
datatype in databse which I use is DateTime.
When I Execute the below code It throws an Exception -
Incorrect syntax near '12'.
Code -
SqlConnection scon;
SqlCommand scom;
protected void Button1_Click(object sender, EventArgs e)
{
scon = new SqlConnection("Data Source=.;Initial Catalog=Goldmine_Database;Integrated Security=True");
string str1 = "Insert Into EmployeeLog$ (Date) Values ("+TextBox1.Text+") ";
scom = new SqlCommand(str1,scon);
scon.Open();
scom.ExecuteNonQuery();
scon.Close();
}
Jquery Script-
<script type="text/javascript">
$(function () {
$('[id$=TextBox1]').datepicker({
dateFormat: "dd/MM/yy",
showOn: "button",
buttonImage: "images/DateTime/Calendar.png",
buttonImageOnly: true,
changeMonth: true,
changeYear: true
});
});
</script>
How to Insert Date in Database ?