Results 1 to 13 of 13
  1. #1
    Join Date
    Sep 2003
    Posts
    69

    Unanswered: Datetime returns NULL from stored proc in VB

    I execute a stored procedure in VB and get several results... the last one (a date time field) is always returned as NULL even though I can see in enterprise manager that it IS infact set... any ideas?

  2. #2
    Join Date
    Aug 2003
    Location
    Andover, MA
    Posts
    256
    How are you retrieving the results? In a recordset or as a command ouput parameter?
    -bpd

  3. #3
    Join Date
    Sep 2003
    Posts
    69
    I'm using ADODB.Recordset

  4. #4
    Join Date
    Aug 2003
    Location
    Andover, MA
    Posts
    256
    Huh. I think we're gonna need to see some code on this one.
    -bpd

  5. #5
    Join Date
    Sep 2003
    Posts
    69
    I am using a record set. Hopefully you are using ADO 2.7 or higher by now...

  6. #6
    Join Date
    Aug 2003
    Location
    Andover, MA
    Posts
    256
    I meant, it would be helpful to see the code you are using, to help troubleshoot the problem.

    But, try inserting this after you retrieve your recordset:

    Dim mField As Field
    For Each mField In mRecordset.Fields
    Debug.Print mField.Name & ": " & mField.Type
    Next mField

    (replacing mRecordset with your recordset name)

    Just to see what datatype is being returned. This may help point to the problem.
    -bpd

  7. #7
    Join Date
    Sep 2003
    Posts
    69
    Thanks, I really appreciate it... I'll try it right now

  8. #8
    Join Date
    Sep 2003
    Posts
    69
    The value of the field type is 135 which is

    Const adDBTimeStamp = 135 (&H87)

  9. #9
    Join Date
    Sep 2003
    Posts
    69
    Any one else got an idea?

  10. #10
    Join Date
    Aug 2003
    Location
    Andover, MA
    Posts
    256
    Is TimeStamp the field type in SQL, or is it supposed to be DateTime? They are not the same.
    -bpd

  11. #11
    Join Date
    Sep 2003
    Posts
    69
    It's a DateTime data type (just checked in EM)... I know they're not the same... I don't know why it's returning time stamp and why it's coming up NULL (I'm retrieving it into a string, then I tried a Date type)

  12. #12
    Join Date
    Aug 2003
    Location
    Andover, MA
    Posts
    256
    As a test, in your sp, try casting the column to be DATETIME in the output query. See if this changes the datatype in VB.
    -bpd

  13. #13
    Join Date
    Sep 2003
    Posts
    69
    I fixed it :-D
    Last edited by trieder; 09-26-03 at 13:56.

Posting Permissions

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