Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2016

    Unanswered: Problem with INSERT INTO

    I have a problem with INSERT INTO.
    My table has a text column.
    Then I pass an empty string as value, the string in the database is '' but not empty. Is this a bug?

    INSERT INTO mytable (txt) VALUES (@txt);
    cmd.Parameters.AddWithVaue("@txt", String.Empty);

  2. #2
    Join Date
    Nov 2003
    Provided Answers: 23
    An empy string '' and NULL are two different things. If you want to store NULL, you need to explicitly send then:

    insert into mytable (txt) values (null);
    is something different then
    insert into mytable values ('');
    I don't know what "cmd.Parameters.AddWithValue()" is doing, but you need to somehow tell your code to send NULL not an empty string.
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags:

    Tips for good questions:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts