locked
Problem with RecordSet RRS feed

  • Question

  • User1754126773 posted

    Had this problem some years ago and now I experience it again, really weird. If I don't fetch the values in RsDoc in the correct order, the values are blank?!?! The result from below is only the icon, RsDoc("module_icon"), every other value is blank.

    'Get startpage FROM db
    SQLStmt = "SELECT st_module.module_startpage, st_module.module_startpage_heading, module_startpage_updated, module_startpage_updatedby, st_module.module_icon FROM st_module WHERE module_id = 301
    Set RsDoc=dbConn.Execute(SQLStmt)
    IF NOT RsDoc.EOF THEN
    strStartPage = "<h1><img src=""../_img/"&RsDoc("module_icon")&"""> "&RsDoc("module_startpage_heading")&"</h1>"&vbcr
    strStartPage = strStartPage + RsDoc("module_startpage")
    strStartPageFooter = "<p class=""desc"">"&mLastModified&": "&RsDoc("module_startpage_updated")&"<br>"&mEditedBy&": "&RsDoc("module_startpage_updatedby")&"</p>"
    ELSE
    strStartPage = "<h1>"&mStartpage&"</h1>"
    END IF
    RsDoc.Close
    SET RsDoc = nothing

    But if I fetch the values in the same order as the SQL Statement, it shows up just fine. Like this:

    'Get startpage FROM db
    SQLStmt = "SELECT st_module.module_startpage, st_module.module_startpage_heading, module_startpage_updated, module_startpage_updatedby, st_module.module_icon FROM st_module WHERE module_id = "&ModuleId
    Set RsDoc=dbConn.Execute(SQLStmt)
    IF NOT RsDoc.EOF THEN
    module_startpage = RsDoc("module_startpage")
    module_startpage_heading = RsDoc("module_startpage_heading")
    module_startpage_updated = RsDoc("module_startpage_updated")
    module_startpage_updatedby = RsDoc("module_startpage_updatedby")

    strStartPage = "<h1><img src=""../_img/"&RsDoc("module_icon")&"""> "&module_startpage_heading&"</h1>"&vbcr
    strStartPage = strStartPage + module_startpage
    strStartPageFooter = "<p class=""desc"">"&mLastModified&": "&module_startpage_updated&"<br>"&mEditedBy&": "&module_startpage_updatedby&"</p>"
    ELSE
    strStartPage = "<h1>"&mStartpage&"</h1>"
    END IF
    RsDoc.Close
    SET RsDoc = nothing

    Got two installations running on different machines at the moment, on one installation I got the problem above, but not on the other machine. Both are Win 7 with IIS7 and SQL Server 2012.

    Sunday, January 6, 2013 9:18 AM

All replies

  • User-1806540432 posted

    Hi,

    Please try below code to create your html page.

            If Not RsDoc.EOF Then
                strStartPage = "<h1><img src=""../_img/" & RsDoc("module_icon") & """> " & RsDoc("module_startpage_heading") & "</h1>" & vbCr
                strStartPage = strStartPage + RsDoc("module_startpage")
                strStartPageFooter = "<p class=""desc"">" & mLastModified & ": " & RsDoc("module_startpage_updated") & "<br>" & mEditedBy & ": " & RsDoc("module_startpage_updatedby") & "</p>"
            Else
                strStartPage = "<h1>" & mStartpage & "</h1>"
            End If

    If it doesn't work, please check the data in the datasource to make sure each field has data.

    There is an article about your issue, it may help you. http://www.motobit.com/tips/detpg_rshtml/ 

    Best Regards,

    Wednesday, January 9, 2013 1:31 AM
  • User1754126773 posted

    Putting blank around & doesn't change anything. I've experienced this on a few rare occasions and really can't understand why...

    Wednesday, January 16, 2013 2:54 AM
  • User-1806540432 posted

    I've experienced this on a few rare occasions and really can't understand why...

    Hi,

    Would you please  tell us when it will happen? Did your columns in the Recordset have data ?

    Thanks.

    Wednesday, January 16, 2013 9:33 PM
  • User1754126773 posted

    Yes, the recordset contain data. If you look at the problem description above you can see it's the same SQL query. One alternative shows up right, the other doesn't.

    Thursday, January 17, 2013 4:22 PM
  • User-1806540432 posted

    Hi,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Best Regards,

    Friday, January 18, 2013 2:49 AM
  • User-1477460723 posted

    I have seen this problem before and years ago I found an article explaining exactly why it happens - but I can't find it anymore as many Classical ASP resources are disappearing.

    I still have this in my ASP apps. Basically you have to create a SELECT with all char columns first, then number columns and followed by text columns. You then have to store these values into local variables in the same order as defined by the SELECT statement and use those variables.

    If you use the fields directly from the data source in a different order then some text or char data will simply return NULL.

    As I said I make a point of creating a SELECT with that specific order and then retrieve the data in the same order otherwise it simply won't work. This happens since IIS 5 in Windows Server 2003 - the first time I searched for this was around 2004...

    Wednesday, January 23, 2013 5:51 PM