none
Unwanted and unexpected NULL in a SQL Server database RRS feed

  • Question

  • Hi,

     

    I have a problem with creating posts in SQL Server 2000. I use the following lines to create posts in a table (oCmd is a IDBCommand object filled with IDataParameters):

     

    oCmd.CommandType = CommandType.Text

    iRowsAffected = oCmd.ExecuteNonQuery()

     

    My problem is that some of the fields in the created post has the value NULL. This is very unexpected since I have debugged the execution and verified that all parameters has the value "" (empty string). No parameters has NULL as value!!! It is also strange that the created fields sometimes has NULL and sometimes has "" (empty string).

     

    Does anyone have a clue regarding this problem?

     

    Best

    /JaHe

    Saturday, October 20, 2007 4:18 PM

All replies

  • You're going to need to provide more info.  In particular, the SQL statement (oCmd.CommandText) and the code you are using to set the parameters.

     

    The only thing I can think of that matches what you described so far would be a trigger in the database assigning NULL to these columns.

     

    Also, are you sure that these parameters really contain empty strings.  In Visual Basic, the expression Nothing = "" evaluates to true.

    Saturday, October 20, 2007 11:47 PM