I've used an ajax calendarExtender tool and set Format to dd/MM/yyyy while inserting the date 21/12/2013 to mysql its giving error
MySqlConnection conn = new MySqlConnection(cnnstring);
string cmdText = "INSERT INTO trydate(Dob) VALUES ('" + TextBox1.Text + "')";
MySqlCommand cmd = new MySqlCommand(cmdText, conn);
conn.Open();
int a = cmd.ExecuteNonQuery();
Label1.Text = "Data Saved";
TextBox1.Text = "";
please help me to overcome from this.
Lillian Martin
11-Dec-2014Use DateTime.ParseExact Method to convert TextBox1.Text to a DateTime variable, and change your query to parameterized query to avoid SQL injection. Also, use using statement to make sure that conn is closed after executing cmd.ExecuteNonQuery()
Anurag Sharma
11-Dec-2014Try this,