0

hi all

I want to ask what wrong with my code.
It gives me error :

MySqlException unhandled
Incorrect datetime value: '08/03/2011 00:00:00' for column 'Date' at row 1

the code is below:

private void btnsave_Click(object sender, EventArgs e)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("", false);
            DateTime datedt = Convert.ToDateTime(tbdate.Text);
            Decimal pricedec = Convert.ToDecimal(tbprice.Text);
            string insert="insert into tbl1(Date,Price)values('"+ datedt + "','"+            pricedec + "')";
            MySqlCommand cmdinsert = new MySqlCommand(insert,conn);
            conn.Open();
            cmdinsert.ExecuteNonQuery();
            conn.Close();



        }

in TextBox tbdate i fill :"08/03/2011"
CurrentCulture is"en-US'

how to solve ?

thank you

danny

Edited by pyTony: fixed formatting

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Ketsuekiame
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.