Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004

    Unanswered: SQLDMO: QueryResults::GetColumnString() on BIT, DECIMAL, etc. does not honour NULLs

    Hi all,

    I'm getting buggy results from SQLDMO against SQLServer2K.

    The QueryResults COM class's GetColumnString() doesn't seem to return NULL when it should (i.e. on row & col values that actually contain NULL!). This occurs on BIT, DECIMAL, FLOAT (SMALL)MONEY, REAL and NUMERIC columns, but not on columns of other datatypes.

    Has anybody worked around this problem? Is it known to be a bug? I'm using a VS.NET-generated COM Interop wrapper and C#.

    Is SQLDMO.Server.ExecuteWithResultsAndMessages() the only way of getting at the server-generated messages (such as "Line 10: error blah blah", or the output of PRINT commands, for example)?

    Many thanks in advance,


  2. #2
    Join Date
    Jul 2007
    Hi domone

    I came across this problem also and was dissapointed to see no replies to your question. Anyway, i did use a workaround - it may or may not be of any use to you:

    I created two QueryResults objects - objResults and objResults2. One contains the data:

    Set objResults = objDB.ExecuteWithResults("select field1, field2 from table")

    and the other contains a corresponding result set which indicates whether each field is null or not

    Set objResults2 = objDB.ExecuteWithResults("select datalength(field1), datalength(field2) from table)

    This way, I can use the same row, col indexes to cross reference the second QueryResults object and check if a field is null


    For iRow = 1 To objResults.Rows

    For iCol = 1 To objResults.Columns

    ' Null check
    If objResults2.GetColumnString(iRow, iCol) = "" Then
    MsgBox("Value is NULL")
    MsgBox("Value is " & objResults.GetColumnString(iRow, iCol)
    End If



    Note: The t-sql datalength function returns the value NULL when the column value is NULL. This gets converted to an empty string through GetColumnString.

Posting Permissions

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