473,378 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

compare variables that contain text

Hi,

I was wondering how do you compare variables that contain text strings in
ASP.

When I use the following If.. Then statement:

If Rs("StyleNo") <> arrStyleNo(aCount) Then
I always get the following error when I try to browse the page:

Error Type:
(0x80020009)
Exception occurred.
Thanks.

Peter
Jul 19 '05 #1
3 5432
Does Rs("StyleNo") contain a NULL value?

If so, do something like:

If CStr(RS.Fields("StyleNo").Value & "") <> CStr(arrStyleNo(aCount)) then
...
End If

Cheers
Ken

"Peter" <pe***@visors.com.hk> wrote in message
news:bk*********@imsp212.netvigator.com...
: Hi,
:
: I was wondering how do you compare variables that contain text strings in
: ASP.
:
: When I use the following If.. Then statement:
:
: If Rs("StyleNo") <> arrStyleNo(aCount) Then
:
:
: I always get the following error when I try to browse the page:
:
: Error Type:
: (0x80020009)
: Exception occurred.
:
:
: Thanks.
:
: Peter
:
:
Jul 19 '05 #2
Try a CStr() around each to force the type

--
----------------------------------------------------------
Curt Christianson (Software_AT_Darkfalz.Com)
Owner/Lead Designer, DF-Software
http://www.Darkfalz.com
---------------------------------------------------------
...Offering free scripts & code snippits for everyone...
---------------------------------------------------------
"Peter" <pe***@visors.com.hk> wrote in message
news:bk*********@imsp212.netvigator.com...
Hi,

I was wondering how do you compare variables that contain text strings in
ASP.

When I use the following If.. Then statement:

If Rs("StyleNo") <> arrStyleNo(aCount) Then
I always get the following error when I try to browse the page:

Error Type:
(0x80020009)
Exception occurred.
Thanks.

Peter

Jul 19 '05 #3
Hi,

Thanks for the advice. But I found out where the problem was coming from.

The error "Error Type (0x80020009) Exception occurred" came from having the
"If..Then" statement come after the Rs.Movenext. When the object
Rs.Movenext went past the last record , Rs("StyleNo") did not contain
anything in it any more. So it came up with an error. Here is more of the
code that I was working on.

SQLstmt = "SELECT * FROM tblQuotation WHERE UserName='" &
Session("username") & "' ORDER BY StyleNo, Color"
Set Rs = conn.execute(SQLstmt)
Do While Not Rs.EOF
Response.Write "Your Contract No is " & Rs("ContractNo") & "<br>"
Response.Write "<table border='1' width='200'>"
aCount = aCount + 1
arrStyleNo(aCount) = Rs("StyleNo")
arrPic(aCount) = Rs("Pic")
Response.Write "<tr><td><B>Style No</B></td><td>" & (arrStyleNo(aCount)) &
" " & Rs("Color") & "</td></tr>"
Response.Write "<tr><td colspan='2' align='right'><A HREF='" &
(arrPic(aCount)) & "'><IMG SRC='" & (arrPic(aCount)) & "' width='153'
height='230'></A></td></tr>"
Response.Write "<tr><td><B>Price</B></td><td> $" & Rs("UnitPrice") &
"</td></tr>"
Response.Write "<tr><td><B>Fabrication</B></td><td>" &Rs("Desc") &
"</td></tr>"
Response.Write "</table>"
Response.Write "<BR><BR>"
Rs.Movenext
If Rs("StyleNo") <> arrStyleNo(aCount) Then
bCount = aCount
aCount = 0
For iCounter = 1 to bCount
Response.Write "Hello"
Next
Else
End If
Loop
Rs.Close
Set Rs = Nothing
In order to solve the problem , I took the If..Then statement an put it
before the Rs.Movenext and I also added more arrays to store the records.
The records of the database would be compared by using the arrays rather
than comparing with Rs object directly. The code that works is as follows:
SQLstmt = "SELECT * FROM tblQuotation WHERE UserName='" &
Session("username") & "' ORDER BY StyleNo, Color"
Set Rs = conn.execute(SQLstmt)
Do While Not Rs.EOF
aCount = aCount + 1
arrStyleNo(aCount) = Rs("StyleNo")
arrColor(aCount) = Rs("Color")
arrDesc(aCount) = Rs("Desc")
arrPic(aCount) = Rs("Pic")
arrT1(aCount) = Rs("T1")
arrT2(aCount) = Rs("T2")
arrT3(aCount) = Rs("T3")
arrUnitPrice(aCount) = Rs("UnitPrice")
arrQty(aCount) = arrT1(aCount) + arrT2(aCount) + arrT3(aCount)
arrAmt(aCount) = arrQty(aCount) * arrUnitPrice(aCount)
Rs.MoveNext
Loop
Rs.Close
Set Rs = Nothing
Response.Write "<table border='0' width='800'>"
For iCounter = 1 to aCount
If NOT arrStyleNo(iCounter -1) = arrStyleNo(iCounter) Then
Response.Write "<tr><td><table border = '1' width=800><tr><td><B>Style
No</B></td><td><B>Color</B></td><td><B>Fabrication</B></td><td><B>T1</B></td
<td><B>T2</B></td><td><B>T3</B></td><td><b>Qty</b></td><td><B>Unit Price</B></td><td><B>Amount</B></td></tr>"
End If
Response.Write "<tr><td>" & arrStyleNo(iCounter) & "</td><td>" &
arrColor(iCounter) & "</td><td>" & arrDesc(iCounter) & "</td><td>" &
arrT1(iCounter) & "</td><td>" & arrT2(iCounter) & "</td><td>" &
arrT3(iCounter) & "</td><td>" & arrQty(iCounter) & "</td><td> $" &
arrUnitPrice(iCounter) & "</td><td> $" & arrAmt(iCounter) & "</td></tr>"
If arrStyleNo(iCounter) <> arrStyleNo(iCounter + 1) Then
Response.Write "<tr><td colspan='9'><table><tr>"
For jCounter = cCount to iCounter
Response.Write "<td><a href='" & arrPic(jCounter) & "'><img src='" &
arrPic(jCounter) & "' width='153' height='230'></a></td>"
Next
cCount = jCounter
Response.Write "</tr></table></td></tr></td></tr></table><tr><td
colspan='9'>&nbsp;</td></tr><tr><td colspan='9'>&nbsp;</td></tr>"
End If
Next
Response.Write "</table><BR><BR>"

End If
I basically placed all of the records into arrays first and then I retrieved
and compared the contents of the arrays using the "For..Next" loops.

Thanks for all the advice.
"Curt_C [MVP]" <software_AT_darkfalz.com> ¦b¶l¥ó
news:%2****************@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g... Try a CStr() around each to force the type

--
----------------------------------------------------------
Curt Christianson (Software_AT_Darkfalz.Com)
Owner/Lead Designer, DF-Software
http://www.Darkfalz.com
---------------------------------------------------------
..Offering free scripts & code snippits for everyone...
---------------------------------------------------------
"Peter" <pe***@visors.com.hk> wrote in message
news:bk*********@imsp212.netvigator.com...
Hi,

I was wondering how do you compare variables that contain text strings in ASP.

When I use the following If.. Then statement:

If Rs("StyleNo") <> arrStyleNo(aCount) Then
I always get the following error when I try to browse the page:

Error Type:
(0x80020009)
Exception occurred.
Thanks.

Peter


Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Peter | last post by:
Hi, I was wondering how do you compare variables that contain text strings in ASP. When I use the following If.. Then statement: If Rs("StyleNo") <> arrStyleNo(aCount) Then
8
by: Sebastian Kerekes | last post by:
Greetings, I'm developing an application that supports multiple languages. In my XSL I use variables to place the text where it belongs to. At the top of the document I include those variables -...
4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
122
by: Einar | last post by:
Hi, I wonder if there is a nice bit twiddling hack to compare a large number of variables? If you first store them in an array, you can do: for (i = 0; i < n; i++) { if (array != value) {...
5
by: VB Programmer | last post by:
I often use session variables to store the user's security level, and other important info. How secure are session variables? Can someone decrypt it and get the information? (This would be...
3
by: Peter | last post by:
ASP.NET 1.1, this is a Intranet application and runs only on IE. I have two webform text boxes which contain dates - starting date and ending date. The dates could be in any format. for...
17
by: Mark A | last post by:
DB2 8.2 for Linux, FP 10 (also performs the same on DB2 8.2 for Windoes, FP 11). Using the SAMPLE database, tables EMP and EMLOYEE. In the followng stored procedure, 2 NULL columns (COMM) are...
10
by: Y2K | last post by:
Any suggestions to compare two values, and if either value changes, then both values now become the changed values. Right now I'm doing it with a textbox and onchange event, but would like to get...
7
by: r.z. | last post by:
This is from Visual Studio docs. But is this standard behaviour? I mean, is it ok in every environment: class A { B* my_pointer; A(); ~A(); }
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.