Hi Everyone,
I have a store procedure returning 7 rows for 3 columns, basically I am retrieving:
Descriptor Lower Range Upper Range
D1 1 10
D2 2 11
D3 3 12
D4 4 13
D5 5 14
D6 6 15
D7 7 16
Now on my ASP page there are Text values that can be entered for Descriptors D1 - D7 and I need to validate the form to ensure that all values for each descriptor mentioned are within the lower and upper range for that descriptor in the look up table.
For example: If I have a user entering value of D4 from the form, than I have to find out if it is between 4-13, if not send them a pop up to say, please enter within that range. Solution I thought:
Get the record set into array in the ASP page and than for each descriptor validate the form value entered is within the range. Problem: Is that I can not get my ASP page to return value more than [3,2] :( My Code in the ASP page is:
[ASP]
<%
Dim ValConn, ValCmd, ValRS, ValParam, ValArray, Region, temp
Dim intLastCol, intLastRow, intRow, intCol
temp = "T"
SET ValConn = Server.CreateObject("ADODB.Connection")
SET ValCmd = Server.CreateObject("ADODB.Command")
SET ValRS = Server.CreateObject("ADODB.Recordset")
Set ValParam=Server.CreateObject("ADODB.Parameter")
ValConn.Open Application("Connection")
SET ValCmd.ActiveConnection = ValConn
ValCmd.CommandType = 4
ValCmd.CommandText = "sp_Validate_Range_Values"
Set ValParam = ValCmd.CreateParameter("Region", 200,1,1,temp)
ValCmd.Parameters.Append ValParam
SET ValRS = ValCmd.Execute
ValArray = ValRS.GetRows
ValRS.Close
SET ValRS= Nothing
'intLastCol = UBound(ValArray, 1)
'intLastRow = Ubound(ValArray, 2)
'For intRow = 0 to intLastCol
'For intCol = 0 to intLastRow
'Response.Write ValArray(intCol, intRow) & " "
'Next
'Response.Write "<Br>"
'Next
Response.Write ValArray (0,0,)
Response.Write "<Br>"
Response.Write ValArray (0,1)
Response.Write "<Br>"
Response.Write ValArray (0,2)
Response.Write "<Br>"
Response.Write ValArray (1,0)
Response.Write "<Br>"
Response.Write ValArray (1,1)
Response.Write "<Br>"
Response.Write ValArray (1,2)
Response.Write "<Br>"
Response.Write ValArray (2,0)
Response.Write "<Br>"
Response.Write ValArray (2,1)
Response.Write "<Br>"
Response.Write ValArray (2,2)
Response.Write "<Br>"
Response.Write ValArray (3,0)
Response.Write "<Br>"
Response.Write ValArray (3,1)
Response.Write "<Br>"
Response.Write ValArray (3,2)
Response.Write "<Br>"
Response.Write ValArray (4,0)
Response.Write "<Br>"
Response.Write ValArray (4,1)
Response.Write "<Br>"
Response.Write ValArray (4,2)
Response.Write "<Br>"
Response.Write ValArray (5,0)
Response.Write "<Br>"
Response.Write ValArray (5,1)
Response.Write "<Br>"
Response.Write ValArray (5,2)
Response.Write "<Br>"
ValConn.Close
SET ValConn = Nothing
Response.Write("Hello")
%>
[/ASP]
ERROR MESSAGE ON ASP PAGE IS:
D1
D2
D3
1
2
3
10
11
13
Microsoft VBScript runtime error '800a0009'
Subscript out of range: '[number: 3]'
/scidc/test.asp, line 74
I believe the issue is because ASP is making an 2D array whereas I need a 3D array and I tired finding how to get multi dimensional array in ASP but none of them were useful, would be glad if someone can explain what is wrong and what can be a possible solution to make the code work.
Thanks in advance,
Sree
3 1431
It seems you could skip the need for a big array if your SQL query does the testing for you. I have written a sample piece of psuedocode. -
TABLE: Limits
-
-
Descriptor | Lower_Range | Upper_Range
-
D1 1 10
-
D2 2 11
-
D3 3 12
-
D4 4 13
-
D5 5 14
-
D6 6 15
-
D7 7 16
-
SQL: - "SELECT descriptor FROM Limits WHERE Lower_Range >= "& userInput_Lower &" AND Upper_Range <= "& userInput_Uppert &" AND descriptor = '"& userInput_Descriptor &"'"
VBScript Logic: -
<%
-
'// your code which executes the query...
-
'// returns recordset ("rs")
-
-
if rs.eof then
-
system_message = "you must enter a value with the valid range for the "& userInput_Descriptor &" field."
-
'// do some error processing...
-
else
-
'// do regular processing
-
end if
-
%>
-
You could do it your way, though. -
TABLE: Limits
-
-
Descriptor | Lower_Range | Upper_Range
-
D1 1 10
-
D2 2 11
-
D3 3 12
-
D4 4 13
-
D5 5 14
-
D6 6 15
-
D7 7 16
-
SQL:
VBScript Logic: -
<%
-
' your code executes the query, and
-
' returns recordset "rs"
-
-
-
aResults = rs.getRows
-
set rs = nothing
-
-
-
' 2d array will look like this:
-
'============================================
-
'row | descriptor (0) | lower (1) | upper (2)
-
'============================================
-
' 0 D1 1 10
-
' 1 D2 2 11
-
' 2 D3 3 12
-
' et cetera, just like your database table
-
-
-
' To ask, "Did the user enter a valid lower range value for D2?", you would say
-
'
-
' if userInput_Lower >= aResults(1, 1) then
-
' ... yes, is valid, do stuff
-
' else
-
' ... no, is invalid, do stuff
-
' end if
-
-
' Remember: get rows will create enough dimensions to accommodate
-
' the result set. The first number of the array represents the "column",
-
' the second number, the "row."
-
%>
-
You could do it your way, though. -
TABLE: Limits
-
-
Descriptor | Lower_Range | Upper_Range
-
D1 1 10
-
D2 2 11
-
D3 3 12
-
D4 4 13
-
D5 5 14
-
D6 6 15
-
D7 7 16
-
SQL:
VBScript Logic: -
<%
-
' your code executes the query, and
-
' returns recordset "rs"
-
-
-
aResults = rs.getRows
-
set rs = nothing
-
-
-
' 2d array will look like this:
-
'============================================
-
'row | descriptor (0) | lower (1) | upper (2)
-
'============================================
-
' 0 D1 1 10
-
' 1 D2 2 11
-
' 2 D3 3 12
-
' et cetera, just like your database table
-
-
-
' To ask, "Did the user enter a valid lower range value for D2?", you would say
-
'
-
' if userInput_Lower >= aResults(1, 1) then
-
' ... yes, is valid, do stuff
-
' else
-
' ... no, is invalid, do stuff
-
' end if
-
-
' Remember: get rows will create enough dimensions to accommodate
-
' the result set. The first number of the array represents the "column",
-
' the second number, the "row."
-
%>
-
Thanks a lot for you help. Much appreciate.
Sree
Sign in to post your reply or Sign up for a free account.
Similar topics
by: ip4ram |
last post by:
I used to work with C and have a set of libraries which allocate
multi-dimensional arrays(2 and 3) with single malloc call.
data_type **myarray
=...
|
by: Ruben |
last post by:
I'm trying to pass an array of string to a function without knowing how
many strings I have beforehand.
I've defined one functions as
char * insert(char table,int cols, char values);
out of...
|
by: rguti |
last post by:
Hi,
How do I create a two dimensional array?
I have created a one dimensional doing this:
Dim laFields As ArrayList = New ArrayList
How about to do a 2 dimensional?
|
by: Peter Olcott |
last post by:
I need to know how to get the solution mentioned below to work. The
solution is from gbayles Jan 29 2001, 12:50 pm, link is provided below:
>...
|
by: spam.noam |
last post by:
Hello,
I discovered that I needed a small change to the Python grammar. I
would like to hear what you think about it.
In two lines:
Currently, the expression "x" is a syntax error.
I suggest...
|
by: fniles |
last post by:
I need to store information in a 2 dimensional array. I understand ArrayList
only works for a single dimensional array, is that correct ?
So, I use the 2 dimensional array like in VB6. I pass the...
|
by: per9000 |
last post by:
Hi all,
I have a two-dimensional array of data, f.x int's. We can imagine that
the array is "really large". Now I want the data in it and store this
in a one-dimensional array.
The obvious...
|
by: Peter Olcott |
last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a
I think that the operator() member function does not work correctly, does
anyone else know how to make a template for making two...
|
by: nelly0 |
last post by:
developing a program that will manipulate noise levels (measured in decibels) that is collected by car manufacturers. These noise levels are produced at seven different speeds by a maximum of six...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |