SQL2000 recordset returns 'undefined' intermittently

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default SQL2000 recordset returns 'undefined' intermittently



    I am connecting to an SQL 2000 database with OLE. My
    connection is fine and records are returned, but certain
    field names seem to cause empty or undefined records to
    return. If I then move the recordset request that returned
    undefined to a different position, it will return a value,
    but everything below it will return undefined!

    The problem variable in the code below is "Hours".

    This is driving me nuts. I had the same problem in a
    different script with the word 'Name'. I had to fix it by
    changing the field name to B_name in the database.

    I can't figure it out, please help.

    the code is below,

    clegg

    //define Connect and create the database object
    Connect = Server.CreateObject("ADODB.Connection");

    //open the stream to the database
    Connect.Open(FilePath);

    //create the record set
    rs = Server.CreateObject("ADODB.RecordSet");
    rs.Open(sql,Connect);


    //******** if I move these three lines below the 'Hours'
    recordset request, they will return undefined ***//
    breakfast = String(rs("Hour_breakfast"));
    lunch = String(rs("Hour_lunch"));
    dinner = String(rs("Hour_dinner"));

    //******* With this call here it will return undefined ***/
    hours = String(rs("Hours"));

    rs.Close();
    Connect.Close();
    clegg Guest

  2. Similar Questions and Discussions

    1. sql2000 backwards
      i made the mistake of getting the enterprise evaluation edition that will soon expire. i just purchased the developer edition and am wondering how...
    2. CF, SQL2000, and XML
      Long story short, I need to create an XML file from a SQL table preferably with CF. Right now I'm using a test table just to figure out how to do...
    3. #25434 [Bgs]: Include command with UTF-8 file returns undefined character
      ID: 25434 Updated by: moriyoshi@php.net Reported By: JanKarnik at atlas dot cz Status: Bogus Bug Type: ...
    4. #25434 [NEW]: Include command with UTF-8 file returns undefined character
      From: JanKarnik at atlas dot cz Operating system: Win2K+iis PHP version: 4.3.3 PHP Bug Type: *General Issues Bug...
    5. Looking into a recordset until it returns a result
      I currently connect to two servers. One is IIS, that runs my asp and sql server, and the other is an AS400, that also cranks out data. Sometimes I...
  3. #2

    Default Re: SQL2000 recordset returns 'undefined' intermittently

    Hmm, "Hours" does not seem to be a reserved word
    ([url]http://www.aspfaq.com/show.asp?id=2080[/url]), but you might try bracketing it
    (Select ..., [Hours], ... ) in your query just to make sure.

    Just to be sure, Hours is not a Text column is it? How about the other three
    columns that are giving you the problem?

    Try doing a
    Response.Write(rs.GetString(,";","<BR>"));
    (almost forgot you were using jscript ... ) just as a quick check on the
    contents of your recordset.

    If this does not help, show us the Select clause of your SQL statement
    (you're not using "select *", I hope)

    HTH,
    Bob Barrows

    clegg wrote:
    > I am connecting to an SQL 2000 database with OLE. My
    > connection is fine and records are returned, but certain
    > field names seem to cause empty or undefined records to
    > return. If I then move the recordset request that returned
    > undefined to a different position, it will return a value,
    > but everything below it will return undefined!
    >
    > The problem variable in the code below is "Hours".
    >
    > This is driving me nuts. I had the same problem in a
    > different script with the word 'Name'. I had to fix it by
    > changing the field name to B_name in the database.
    >
    > I can't figure it out, please help.
    >
    > the code is below,
    >
    > clegg
    >
    > //define Connect and create the database object
    > Connect = Server.CreateObject("ADODB.Connection");
    >
    > //open the stream to the database
    > Connect.Open(FilePath);
    >
    > //create the record set
    > rs = Server.CreateObject("ADODB.RecordSet");
    > rs.Open(sql,Connect);
    >
    >
    > //******** if I move these three lines below the 'Hours'
    > recordset request, they will return undefined ***//
    > breakfast = String(rs("Hour_breakfast"));
    > lunch = String(rs("Hour_lunch"));
    > dinner = String(rs("Hour_dinner"));
    >
    > //******* With this call here it will return undefined ***/
    > hours = String(rs("Hours"));
    >
    > rs.Close();
    > Connect.Close();


    Bob Barrows Guest

  4. #3

    Default Re: SQL2000 recordset returns 'undefined' intermittently

    > THE REASON (as far as I can tell):
    >
    > When a forward only cursor accesses the db it copies the
    > recordset into local memory and makes all calls to the
    > recordset from there.
    > The static cursor on the other hand takes it's values
    > straight from the database as it needs them.
    > I believe that at the time the forward only cursor was
    > copying the data to local memory, something interrupts it
    > and it misses a few values, leaving some vars undefined.
    > since it then uses this memory, OOPS undefined.
    > Static just asks for the data till it gets it.
    I've never experienced this ...


    Aaron Bertrand - MVP Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139