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

    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
    Posts
    2,914
    Provided Answers: 8
    An empy string '' and NULL are two different things. If you want to store NULL, you need to explicitly send then:

    Code:
    insert into mytable (txt) values (null);
    is something different then
    Code:
    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: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

Posting Permissions

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