|
 |
asp_databases thread: Random error if "" is not added to a field in a recordset
Message #1 by "sara" <fillet70@h...> on Fri, 14 Feb 2003 16:52:41
|
|
I'm using ASP and ADO to connect to an access database.
I execute the sql and store the results in a recordset object.
oRs(0) is a number in the database and has a valid value for the record
that was retrieved. I assign this to a variable. When i try to use the
variable i get an error sometimes.
This does not happen with all recordset fields.
If i add empty quotes ("") to oRs(0) before assigning it to the variable,
things work ok. Why does this happen?
The disadvantage of this is when i add "", the variable is a string and i
have to convert it to a number when i use it.
Regards,
sara
Message #2 by Sam Clohesy <samc@e...> on Fri, 14 Feb 2003 17:25:47 -0000
|
|
Can you send some code?
Cheers
Sam
Sam Clohesy
Project Manager
T: 0208 772 3958
E: samc@e...
W: http://www.etypemedia.co.uk
W: http://www.siteactive.net
-----Original Message-----
From: sara [mailto:fillet70@h...]
Sent: 14 February 2003 16:53
To: ASP Databases
Subject: [asp_databases] Random error if "" is not added to a field in a
recordset
I'm using ASP and ADO to connect to an access database.
I execute the sql and store the results in a recordset object.
oRs(0) is a number in the database and has a valid value for the record
that was retrieved. I assign this to a variable. When i try to use the
variable i get an error sometimes.
This does not happen with all recordset fields.
If i add empty quotes ("") to oRs(0) before assigning it to the variable,
things work ok. Why does this happen?
The disadvantage of this is when i add "", the variable is a string and i
have to convert it to a number when i use it.
Regards,
sara
Message #3 by "sara" <fillet70@h...> on Fri, 14 Feb 2003 17:50:05
|
|
oConn = Server.CreateObject("ADODB.Connection");
oConn.Open("TimeReportingDSN");
oRs = Server.CreateObject("ADODB.Recordset");
user_found = "Y"
sql="select user_id from USER where company_id = " + company_id + " and
login = '" + login + "'"
oRs=oConn.Execute(sql);
if (oRs.EOF)
{
msg="User not found"
user_found = "N"
}
else
{
user_id = oRs(0);
}
}
> Can you send some code?
Cheers
Sam
Sam Clohesy
Project Manager
T: 0208 772 3958
E: samc@e...
W: http://www.etypemedia.co.uk
W: http://www.siteactive.net
-----Original Message-----
From: sara [mailto:fillet70@h...]
Sent: 14 February 2003 16:53
To: ASP Databases
Subject: [asp_databases] Random error if "" is not added to a field in a
recordset
I'm using ASP and ADO to connect to an access database.
I execute the sql and store the results in a recordset object.
oRs(0) is a number in the database and has a valid value for the record
that was retrieved. I assign this to a variable. When i try to use the
variable i get an error sometimes.
This does not happen with all recordset fields.
If i add empty quotes ("") to oRs(0) before assigning it to the variable,
things work ok. Why does this happen?
The disadvantage of this is when i add "", the variable is a string and i
have to convert it to a number when i use it.
Regards,
sara
Message #4 by "Swathi Pathak" <swathi@a...> on Fri, 14 Feb 2003 10:50:26 -0800
|
|
Hi Sara,
Looks like you are using JSCRIPT.
Use oRs(0).value instead of oRs(0)
-swathi-
=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D
-=3D-=3D-=3D
Swathi Pathak
Alert Technologies Corporation
4625 First st, Suite 110
Pleasanton, CA 94566
Tel: (xxx) xxx-xxxx Extn: 21
Email : mailto:swathi@a...
=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D
-=3D-=3D-=3D
> -----Original Message-----
> From: sara [mailto:fillet70@h...]
> Sent: Friday, February 14, 2003 9:50 AM
> To: ASP Databases
> Subject: [asp_databases] RE: Random error if "" is not added
> to a field
> in a recordset
>
>
> oConn =3D Server.CreateObject("ADODB.Connection");
> oConn.Open("TimeReportingDSN");
> oRs =3D Server.CreateObject("ADODB.Recordset");
> user_found =3D "Y"
>
> sql=3D"select user_id from USER where company_id =3D " +
> company_id + " and
> login =3D '" + login + "'"
> oRs=3DoConn.Execute(sql);
> if (oRs.EOF)
> {
> msg=3D"User not found"
> user_found =3D "N"
> }
> else
> {
> user_id =3D oRs(0);
> }
> }
>
>
>
> > Can you send some code?
>
> Cheers
>
> Sam
>
> Sam Clohesy
> Project Manager
> T: 0208 772 3958
> E: samc@e...
> W: http://www.etypemedia.co.uk
> W: http://www.siteactive.net
>
>
> -----Original Message-----
> From: sara [mailto:fillet70@h...]
> Sent: 14 February 2003 16:53
> To: ASP Databases
> Subject: [asp_databases] Random error if "" is not added to a
> field in a
> recordset
>
>
> I'm using ASP and ADO to connect to an access database.
> I execute the sql and store the results in a recordset object.
> oRs(0) is a number in the database and has a valid value for
> the record
> that was retrieved. I assign this to a variable. When i try
> to use the
> variable i get an error sometimes.
> This does not happen with all recordset fields.
> If i add empty quotes ("") to oRs(0) before assigning it to
> the variable,
> things work ok. Why does this happen?
> The disadvantage of this is when i add "", the variable is a
> string and i
> have to convert it to a number when i use it.
>
> Regards,
> sara
>
Message #5 by "sara" <fillet70@h...> on Fri, 14 Feb 2003 21:39:52
|
|
Hi Swathi,
Thank you. That worked. I still dont understand why it works cause i'm
using ADO and the properties on the recordset object should have nothing
to do with whether i'm using Javascript or JSCRIPT.
Also, i dont understand why the oRs(0)(without the value) works most of
the times but gives an error occasionally.
If you know the answer, please let me know.
Regards,
Sara
> Hi Sara,
Looks like you are using JSCRIPT.
Use oRs(0).value instead of oRs(0)
-swathi-
=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-
=3D
-=3D-=3D-=3D
Swathi Pathak
Alert Technologies Corporation
4625 First st, Suite 110
Pleasanton, CA 94566
Tel: (xxx) xxx-xxxx Extn: 21
Email : mailto:swathi@a...
=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-
=3D
-=3D-=3D-=3D
> -----Original Message-----
> From: sara [mailto:fillet70@h...]
> Sent: Friday, February 14, 2003 9:50 AM
> To: ASP Databases
> Subject: [asp_databases] RE: Random error if "" is not added
> to a field
> in a recordset
>
>
> oConn =3D Server.CreateObject("ADODB.Connection");
> oConn.Open("TimeReportingDSN");
> oRs =3D Server.CreateObject("ADODB.Recordset");
> user_found =3D "Y"
>
> sql=3D"select user_id from USER where company_id =3D " +
> company_id + " and
> login =3D '" + login + "'"
> oRs=3DoConn.Execute(sql);
> if (oRs.EOF)
> {
> msg=3D"User not found"
> user_found =3D "N"
> }
> else
> {
> user_id =3D oRs(0);
> }
> }
>
>
>
> > Can you send some code?
>
> Cheers
>
> Sam
>
> Sam Clohesy
> Project Manager
> T: 0208 772 3958
> E: samc@e...
> W: http://www.etypemedia.co.uk
> W: http://www.siteactive.net
>
>
> -----Original Message-----
> From: sara [mailto:fillet70@h...]
> Sent: 14 February 2003 16:53
> To: ASP Databases
> Subject: [asp_databases] Random error if "" is not added to a
> field in a
> recordset
>
>
> I'm using ASP and ADO to connect to an access database.
> I execute the sql and store the results in a recordset object.
> oRs(0) is a number in the database and has a valid value for
> the record
> that was retrieved. I assign this to a variable. When i try
> to use the
> variable i get an error sometimes.
> This does not happen with all recordset fields.
> If i add empty quotes ("") to oRs(0) before assigning it to
> the variable,
> things work ok. Why does this happen?
> The disadvantage of this is when i add "", the variable is a
> string and i
> have to convert it to a number when i use it.
>
> Regards,
> sara
>
Message #6 by "Ken Schaefer" <ken@a...> on Mon, 17 Feb 2003 16:49:09 +1100
|
|
oRS(0) returns a *field object* not a string or integer. There are no
"default properties" in JScript, only VBScript/VB/VBA:
With VBScript you can do:
oRS(0)
because .Value is the default property of the Field object that is being
referenced in the Fields collection of oRS.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "sara" <fillet70@h...>
Subject: [asp_databases] RE: Random error if "" is not added to a field in a
recordset
: Hi Swathi,
: Thank you. That worked. I still dont understand why it works cause i'm
: using ADO and the properties on the recordset object should have nothing
: to do with whether i'm using Javascript or JSCRIPT.
: Also, i dont understand why the oRs(0)(without the value) works most of
: the times but gives an error occasionally.
:
: If you know the answer, please let me know.
:
: Regards,
: Sara
:
:
: > Hi Sara,
: Looks like you are using JSCRIPT.
: Use oRs(0).value instead of oRs(0)
: -swathi-
|
|
 |