locked
C# insert null value in mysql RRS feed

  • Question

  • Dear all,

     DbCommand lcDbCommand = this.dbConn.CreateCommand();
     lcDbCommand.CommandText ="insert into table1 (delete_date) Values ( NULL)";

    or  lcDbCommand.CommandText ="insert into table1 (delete_date) Values ('" + dbnull.value + "')";

    When inserting null values into mysql through C#, it does not work, The value 0001-01-01... will be inserted.

    I want the Null value is inserted into column in MYSQL. How to do? I don't want any sql parameter.

    Friday, May 25, 2012 7:44 AM

Answers

  • Sorry I have done something in my program.

    It should work to insert null value as I have another code which update the field to be min date.

    Just ignore this and it is working now.

    • Marked as answer by Raymond Chiu Friday, May 25, 2012 7:58 AM
    Friday, May 25, 2012 7:58 AM

All replies

  • Sorry I have done something in my program.

    It should work to insert null value as I have another code which update the field to be min date.

    Just ignore this and it is working now.

    • Marked as answer by Raymond Chiu Friday, May 25, 2012 7:58 AM
    Friday, May 25, 2012 7:58 AM
  • Just ignore this and it is working now.

    Glad to hear that.

    Best Regards,


    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, May 28, 2012 7:42 AM