1
Answer

insertind date problem

anil wagavkar

anil wagavkar

8y
398
1
when i insert date in database using calenderextender i have error 
 
 "Incorrect syntax near '24-03-2016 00:00:00'. "
 
  my code.
 
protected void Button2_Click(object sender, EventArgs e)
{
 DateTime? joingdate;
 joingdate = DateTime.ParseExact(joing.Text, "dd/MM/yyyy",null);
SqlCommand cmd = new SqlCommand("insert into acmaster(Name,Addr1,Mobile,Emailid,Panno,Nominee,Relation,Sponcerid,Sponcustno,Itemcode,Itemprice,commission,joing)values('" + customer.Text + "','" + adderss.Text + "','" + mobile.Text + "','" + emailid.Text + "','" + panno.Text + "','" + nomineen.Text + "','" + nomineer.Text + "','" + rankcode.Text + "','" + custno.Text + "','" + productid.Text + "','" + prize.Text + "','"+commission.Text+"'.'"+d+"')", con);
cmd.CommandType = CommandType.Text;
try
{
con.Open();
cmd.ExecuteNonQuery();
// Label25.Text = "data Inserted";
Response.Write("<script>alert('Data Save....')</script>");
con.Close();
clearfield();
}
catch (Exception ex)
{
Label25.Text = ex.Message;
}
}
 
Answers (1)