Ask a Question related to ASP Database, Design and Development.
-
clegg #1
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
-
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... -
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... -
#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: ... -
#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... -
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... -
Bob Barrows #2
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
-
Aaron Bertrand - MVP #3
Re: SQL2000 recordset returns 'undefined' intermittently
> THE REASON (as far as I can tell):
I've never experienced this ...>
> 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.
Aaron Bertrand - MVP Guest



Reply With Quote

