Cannot get the field value from ADODB recordset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • narutodc
    New Member
    • Apr 2007
    • 3

    Cannot get the field value from ADODB recordset

    Hi,

    I'm working on an ASP Jscript page run on IIS 5. However i got a very strange problem:

    The code is like this

    Code:
    var rs = getPaymentDetail(pId);//Get the ADODB record set
    this.paymentId = pId;
    this.agreementId = String(rs("AgreementId"));
    this.supplierId = String(rs("SupplierId"));
    this.supplierName = String(rs("SupplierName"));
    Response.Write(rs.Fields(10).Value+"----");
    The Response.Write write out: undefined------
    But if i move this line up 1 or more line: before the rs("SupplierNam e"), it can write out the correct value.

    I also try to write all the column in numeric order before doing anything to the recordset, this work perfectly fine, and list all the column with value correctly.
    Code:
    for (var i=0; i<rs.Fields.Count; i++)
        Response.Write(i+" "+rs.Fields(i).Name+" "+rs.Fields(i).Value+"<br />");
    I think it has something to do with the order we call the recordset field.

    Anyone have any idea why this happen?

    Thanks
  • narutodc
    New Member
    • Apr 2007
    • 3

    #2
    Btw, if I call this first,
    Code:
    for (var i=0; i<rs.Fields.Count; i++)
        Response.Write(i+" "+rs.Fields(i).Name+" "+rs.Fields(i).Value+"<br />");
    Then I can get all the fields of that recordset in any order correctly for the current row, if I do a moveNext, then the problem apear again.

    Comment

    • narutodc
      New Member
      • Apr 2007
      • 3

      #3
      I have found the source of the problem, it has something to do with the 'text' data type of Sybase, and not with ASP. Still I cannot find any document on that topic :(

      Comment

      • camilokorea
        New Member
        • Oct 2008
        • 1

        #4
        I had the same issue with sql2005.

        the field in my data base table that I was trying to print out using ASP is a nvarchar(MAX).

        For solve the issue, that thing that I did was update the stored procedure that retrieve me the field value using something like this:

        select
        cast(table_colu mn as varchar(3000)) as [name_of_column]
        -- the column is delimited to just 3000 characters
        from
        table
        where
        blah blah blah

        Seems to be an issue with ADODB and the length of char column types with lenght of MAX

        I hope that this works for you...

        Comment

        • narayananbabun
          New Member
          • Feb 2008
          • 4

          #5
          Yeah if in your table u have a field of datatype Text then u cannot use the recordset in any order if u use like that then u wont be able to get the value

          Comment

          Working...