473,770 Members | 4,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help in writing SQL using request.form.it em(i)

I am using the following to create an SQL statement
using the names and values from request.form.
The loop goes through each item in request.form

The issue comes in having an additional "and" at the end
of the loop and the value of x3 as not all options may be selected
from the form yet the loop goes through the entire request.form list

I have to add addtional code to strip off the last "and"
and was wondering if there is a way to eliminate the additional
code needed for stripping the "and".

Is there a way to determine which is the very last request.form.it em(i)
that has a .key value and use that as x3? I would imagine I would not
need the additional code if there is a way to determine this.

Any help is appreciated
for j = 2 to Request.Form.co unt()
x2= x2 & request.form.it em(j)
next
if len(rtrim(x2)) = 0 then
response.write "no options chosen"
else
whereby= ""
x3=Request.Form .count
for i = 2 to Request.Form.co unt()
if len(trim(reques t.form(i))) 0 then
if request.form.ke y(i) = "MFR" then
whereby = whereby & " (Mfg1='" & request.form.it em(i) & "' or mfg2='" &
request.form.it em(i) & "' or mfg3='" & request.form.it em(i) & "') AND "
elseif request.form.ke y(i) <"MFR" then whereby = whereby &
trim(request.fo rm.key(i)) & "='" & Request.Form.it em(i) & "' AND "
elseif i=x3 then whereby = whereby & trim(request.fo rm.key(i)) & "='" &
Request.Form.it em(i) & "' "
end if
end if
next

' Needed to strip last AND from statement
x4=mid(rtrim(wh ereby),len(rtri m(whereby))-3,4)
if trim(x4) = "AND" then
whereby = mid(rtrim(where by),1,len(rtrim (whereby))-3) & "order by rec_no "
& Updown
else
whereby=whereby & "order by rec_no " & Updown
end if
' End additional Code

sql = sql & whereby
Oct 11 '06 #1
4 3768
if j= Request.Form.co unt() then
whereby = whereby & ...
else
whereby = whereby & ... & "AND"
end if
"Michael Kujawa" <nof at kujawas dot netwrote in message news:uu******** ******@TK2MSFTN GP04.phx.gbl...
>I am using the following to create an SQL statement
using the names and values from request.form.
The loop goes through each item in request.form

The issue comes in having an additional "and" at the end
of the loop and the value of x3 as not all options may be selected
from the form yet the loop goes through the entire request.form list

I have to add addtional code to strip off the last "and"
and was wondering if there is a way to eliminate the additional
code needed for stripping the "and".

Is there a way to determine which is the very last request.form.it em(i)
that has a .key value and use that as x3? I would imagine I would not
need the additional code if there is a way to determine this.

Any help is appreciated
for j = 2 to Request.Form.co unt()
x2= x2 & request.form.it em(j)
next
if len(rtrim(x2)) = 0 then
response.write "no options chosen"
else
whereby= ""
x3=Request.Form .count
for i = 2 to Request.Form.co unt()
if len(trim(reques t.form(i))) 0 then
if request.form.ke y(i) = "MFR" then
whereby = whereby & " (Mfg1='" & request.form.it em(i) & "' or mfg2='" &
request.form.it em(i) & "' or mfg3='" & request.form.it em(i) & "') AND "
elseif request.form.ke y(i) <"MFR" then whereby = whereby &
trim(request.fo rm.key(i)) & "='" & Request.Form.it em(i) & "' AND "
elseif i=x3 then whereby = whereby & trim(request.fo rm.key(i)) & "='" &
Request.Form.it em(i) & "' "
end if
end if
next

' Needed to strip last AND from statement
x4=mid(rtrim(wh ereby),len(rtri m(whereby))-3,4)
if trim(x4) = "AND" then
whereby = mid(rtrim(where by),1,len(rtrim (whereby))-3) & "order by rec_no "
& Updown
else
whereby=whereby & "order by rec_no " & Updown
end if
' End additional Code

sql = sql & whereby


Oct 11 '06 #2
Hi Jon,

That will not work. I would get the same results as
the request.form.co unt() returns the entire set.

I need to know how to find the last .item with a value
and use that for the x3 value, instead of request.form.co unt().
Otherwise the additional AND is still there.

Not sure how to do that.

for example, if I have 22 elements in the form and the last
element chosen is 20 then I need to know that for the value
of for i = 2 to request.form.(? )

count gives the entry set and that is where the issue lies.
The form is a series of checkboxes and dropdown lists
and requires only one item to be chosen, but can have up
to 22 selections.


"Jon Paal" <Jon nospam Paal @ everywhere dot comwrote in message
news:12******** *****@corp.supe rnews.com...
if j= Request.Form.co unt() then
whereby = whereby & ...
else
whereby = whereby & ... & "AND"
end if
"Michael Kujawa" <nof at kujawas dot netwrote in message
news:uu******** ******@TK2MSFTN GP04.phx.gbl...
I am using the following to create an SQL statement
using the names and values from request.form.
The loop goes through each item in request.form

The issue comes in having an additional "and" at the end
of the loop and the value of x3 as not all options may be selected
from the form yet the loop goes through the entire request.form list

I have to add addtional code to strip off the last "and"
and was wondering if there is a way to eliminate the additional
code needed for stripping the "and".

Is there a way to determine which is the very last request.form.it em(i)
that has a .key value and use that as x3? I would imagine I would not
need the additional code if there is a way to determine this.

Any help is appreciated
for j = 2 to Request.Form.co unt()
x2= x2 & request.form.it em(j)
next
if len(rtrim(x2)) = 0 then
response.write "no options chosen"
else
whereby= ""
x3=Request.Form .count
for i = 2 to Request.Form.co unt()
if len(trim(reques t.form(i))) 0 then
if request.form.ke y(i) = "MFR" then
whereby = whereby & " (Mfg1='" & request.form.it em(i) & "' or mfg2='"
&
request.form.it em(i) & "' or mfg3='" & request.form.it em(i) & "') AND "
elseif request.form.ke y(i) <"MFR" then whereby = whereby &
trim(request.fo rm.key(i)) & "='" & Request.Form.it em(i) & "' AND "
elseif i=x3 then whereby = whereby & trim(request.fo rm.key(i)) & "='"
&
Request.Form.it em(i) & "' "
end if
end if
next

' Needed to strip last AND from statement
x4=mid(rtrim(wh ereby),len(rtri m(whereby))-3,4)
if trim(x4) = "AND" then
whereby = mid(rtrim(where by),1,len(rtrim (whereby))-3) & "order by rec_no
"
& Updown
else
whereby=whereby & "order by rec_no " & Updown
end if
' End additional Code

sql = sql & whereby


Oct 11 '06 #3


"Michael Kujawa" <nof at kujawas dot netwrote in message
news:uu******** ******@TK2MSFTN GP04.phx.gbl...
Is there a way to determine which is the very last
request.form.it em(i)
that has a .key value and use that as x3? I would imagine I would not
need the additional code if there is a way to determine this.
>
Any help is appreciated
>
">
"Jon Paal" <Jon nospam Paal @ everywhere dot comwrote in message
news:12******** *****@corp.supe rnews.com...
if j= Request.Form.co unt() then
whereby = whereby & ...
else
whereby = whereby & ... & "AND"
end if
Sorry My Bad... I forgot "No top posting"

Hi Jon,

That will not work. I would get the same results as
the request.form.co unt() returns the entire set.

I need to know how to find the last .item with a value
and use that for the x3 value, instead of request.form.co unt().
Otherwise the additional AND is still there.

Not sure how to do that.

for example, if I have 22 elements in the form and the last
element chosen is 20 then I need to know that for the value
of for i = 2 to request.form.(? )

count gives the entry set and that is where the issue lies.
The form is a series of checkboxes and dropdown lists
and requires only one item to be chosen, but can have up
to 22 selections.

Oct 11 '06 #4

"Michael Kujawa" <nof at kujawas dot netwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
>
>
"Michael Kujawa" <nof at kujawas dot netwrote in message
news:uu******** ******@TK2MSFTN GP04.phx.gbl...
Is there a way to determine which is the very last
request.form.it em(i)
that has a .key value and use that as x3? I would imagine I would
not
need the additional code if there is a way to determine this.

Any help is appreciated

">
"Jon Paal" <Jon nospam Paal @ everywhere dot comwrote in message
news:12******** *****@corp.supe rnews.com...
if j= Request.Form.co unt() then
whereby = whereby & ...
else
whereby = whereby & ... & "AND"
end if
>

Sorry My Bad... I forgot "No top posting"

Hi Jon,

That will not work. I would get the same results as
the request.form.co unt() returns the entire set.

I need to know how to find the last .item with a value
and use that for the x3 value, instead of request.form.co unt().
Otherwise the additional AND is still there.

Not sure how to do that.

for example, if I have 22 elements in the form and the last
element chosen is 20 then I need to know that for the value
of for i = 2 to request.form.(? )

count gives the entry set and that is where the issue lies.
The form is a series of checkboxes and dropdown lists
and requires only one item to be chosen, but can have up
to 22 selections.

Thanks for the help, finally figured it out
I added another loop to get the last number and used that
for j = 2 to Request.Form.co unt()
if len(trim(reques t.form(j))) 0 then
x3=j
end if
next

if len(rtrim(x2)) = 0 then
response.write "no options chosen"
else
whereby= ""
for i = 2 to x3
if len(trim(reques t.form(i))) 0 then
if i = x3 then
whereby = whereby & trim(request.fo rm.key(i)) & "='" &
Request.Form.it em(i) & "' "
exit for
else
if request.form.ke y(i) = "MFR" then
whereby = whereby & " (Mfg1='" & request.form.it em(i) & "' or mfg2='"
& request.form.it em(i) & "' or mfg3='" & request.form.it em(i) & "') AND "
elseif request.form.ke y(i) <"MFR" then whereby = whereby &
trim(request.fo rm.key(i)) & "='" & Request.Form.it em(i) & "' AND "
end if
end if
end if
next
Oct 11 '06 #5

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

Similar topics

0
1519
by: collie | last post by:
Hi, I have an asp page that needs to create 2 different cookies: one for the admin and one for the user. The code that I have to work with was created by someone else. the page first requires to login and if username and password match then the user is redirected to the same page where he sees details of his message. What I have to do is this: in my db i have a table called users with the fields u_id, u_password and access. Access can...
1
8750
by: PT | last post by:
I got a problem. And thats..... First of all, I got these three tables. ------------------- ------------------ ---------------------- tblPerson tblPersonSoftware tblSoftware ------------------- ------------------ ---------------------- PID PName PID* SID* SID SWName --- ----- --- --- --- ------ 1 Thomas 1 1 ...
0
1473
by: ronaldlee | last post by:
I got a collection read only error, below is the error message. Collection is read-only. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NotSupportedException: Collection is read-only.
1
3721
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am attach this script files and inq files. I cant understand this error. Please suggest me. You can talk with my yahoo id b_sahoo1@yahoo.com. Now i am online. Plz....Plz..Plz...
0
5576
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
9
1912
by: TF | last post by:
Hello all, I made a ASP.NET 2.0 site that shows possible "recipes" for paint colors stored in an access dbase. Basically, 1000 colors are stored with specific RGB values in separate columns. A user sees all the colors listed on the page with hyperlinks that open the "mixes" page. The mixes page goes through each record, compares it with all other records in a ratio up to "maxratio". If it finds a ratio that matches the redvalue of...
6
1909
by: kevin | last post by:
Hi I have just changed hosting companys and my mail forms I find this is because new provider does not support CDONT anymore. Below is my original sent asp using CDONT and below that is my attemt to recode using CDO but it does not work. Can anyone plesee enter the missing lines The error
1
2028
by: nth | last post by:
I wan to filter the database show out information by using the user login name. Means that when that user login by entering their names n password, if correct then it will go to the other page by showing that user result only, not other user result. Can somebody help me pls?. Following is the login page code: <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!--#include file="Connections/conResult.asp" --> <% Dim Recordset1__MMColParam...
1
2361
by: valmae | last post by:
Please help anyone! I am getting this error after the submit button is clicked to this form which was designed in Dreamweaver in ASP. Microsoft VBScript compilation error '800a0401' Expected end of statement /Prepare/Earthquake_Awareness_Week_07/Earthquake_drill.asp, line 37 wareness Week Response Form</u></h1><h2>Superintendents Name: </h2>" & request.form("Superintendents Name") _
0
9439
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9882
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.