473,698 Members | 2,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"If valueDB = valueQS then" statement not working

Hi,

I'm utterly confounded by this one. There must be some sort of rule that
I don't know of. I'd consider myself a Newbie+1, so be gentle.

I have a database connection (working A-Ok) and a Query String value from a
form (passed using GET & working Ok). The server is IIS5.

What I'm trying to do is get a simple IF statement to work accross the two
numeric values. Once from a database and one from a Query String.

If %Database value% = %query string value% then
response.write( "something" )
else
response.write( "nothing")
end if

....but it's not working. It always without fail responds with "nothing".
If I response.write the database variable and the query strings the values
are all numeric and there is always going to be a match. There are only 3
records in the database and 3 options on the form.

If I change it to %Database value%=%Databas e value% then it works,
specifying "something" on all the results. If I manually place a numeric
value into the code in place of %Query string value% it works as it should
do, except that of course it's static.

Here is the entire code segment:

<%
checkmcat=Reque st.Querystring( "mstrcat")
SQLREVMCAT="SEL ECT TBL_revmcat.rev mcat_ID, TBL_revmcat.rev mcat_Name FROM
TBL_revmcat ORDER BY TBL_revmcat.rev mcat_Name"
set revmcat = server.createob ject("ADODB.Con nection")
revmcat.open = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
Server.MapPath( "/database.mdb")
set REV_mcat=revmca t.execute(SQLRE VMCAT)
%>

<% do while not REV_mcat.eof %>
<option<% if REV_mcat(0) = checkmcat then
response.write( " SELECTED")
else
response.write( "")
end if %> value="<%= REV_mcat(0) %>">- <%= REV_mcat(1) %></option>
<%REV_mcat.move next
loop%>
<% revmcat.close %>
</select>

revmcat_ID [ REV_mcat(0) ] is a long integer AutoNumber in the Access 2000
database & is the tables Primary Key.
I've come across this before on another project I was fiddling with, in the
end I just completly change the entire database / code to work around the
problem. I can't see away round it this time though.

I guess that it is probably something obvious, or a rule I don't know of.
I've just been staring at it for so long, I'm suffering code blindness.

Thanks.

Chris
Jul 19 '05 #1
3 1759
You might try comparing apples to apples, e.g. if clng(something) =
clng(something_ else) then

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Chris Tilley - HPC:Factor" <ch************ ***@hpcfactor.c om> wrote in
message news:OD******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

I'm utterly confounded by this one. There must be some sort of rule that I don't know of. I'd consider myself a Newbie+1, so be gentle.

I have a database connection (working A-Ok) and a Query String value from a form (passed using GET & working Ok). The server is IIS5.

What I'm trying to do is get a simple IF statement to work accross the two
numeric values. Once from a database and one from a Query String.

If %Database value% = %query string value% then
response.write( "something" )
else
response.write( "nothing")
end if

...but it's not working. It always without fail responds with "nothing".
If I response.write the database variable and the query strings the values
are all numeric and there is always going to be a match. There are only 3
records in the database and 3 options on the form.

If I change it to %Database value%=%Databas e value% then it works,
specifying "something" on all the results. If I manually place a numeric
value into the code in place of %Query string value% it works as it should
do, except that of course it's static.

Here is the entire code segment:

<%
checkmcat=Reque st.Querystring( "mstrcat")
SQLREVMCAT="SEL ECT TBL_revmcat.rev mcat_ID, TBL_revmcat.rev mcat_Name FROM
TBL_revmcat ORDER BY TBL_revmcat.rev mcat_Name"
set revmcat = server.createob ject("ADODB.Con nection")
revmcat.open = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
Server.MapPath( "/database.mdb")
set REV_mcat=revmca t.execute(SQLRE VMCAT)
%>

<% do while not REV_mcat.eof %>
<option<% if REV_mcat(0) = checkmcat then
response.write( " SELECTED")
else
response.write( "")
end if %> value="<%= REV_mcat(0) %>">- <%= REV_mcat(1) %></option> <%REV_mcat.move next
loop%>
<% revmcat.close %>
</select>

revmcat_ID [ REV_mcat(0) ] is a long integer AutoNumber in the Access 2000
database & is the tables Primary Key.
I've come across this before on another project I was fiddling with, in the end I just completly change the entire database / code to work around the
problem. I can't see away round it this time though.

I guess that it is probably something obvious, or a rule I don't know of.
I've just been staring at it for so long, I'm suffering code blindness.

Thanks.

Chris

Jul 19 '05 #2
try using a convert to ensure the same datatype for comparison CStr() or
CInt()
--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Chris Tilley - HPC:Factor" <ch************ ***@hpcfactor.c om> wrote in
message news:OD******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

I'm utterly confounded by this one. There must be some sort of rule that I don't know of. I'd consider myself a Newbie+1, so be gentle.

I have a database connection (working A-Ok) and a Query String value from a form (passed using GET & working Ok). The server is IIS5.

What I'm trying to do is get a simple IF statement to work accross the two
numeric values. Once from a database and one from a Query String.

If %Database value% = %query string value% then
response.write( "something" )
else
response.write( "nothing")
end if

...but it's not working. It always without fail responds with "nothing".
If I response.write the database variable and the query strings the values
are all numeric and there is always going to be a match. There are only 3
records in the database and 3 options on the form.

If I change it to %Database value%=%Databas e value% then it works,
specifying "something" on all the results. If I manually place a numeric
value into the code in place of %Query string value% it works as it should
do, except that of course it's static.

Here is the entire code segment:

<%
checkmcat=Reque st.Querystring( "mstrcat")
SQLREVMCAT="SEL ECT TBL_revmcat.rev mcat_ID, TBL_revmcat.rev mcat_Name FROM
TBL_revmcat ORDER BY TBL_revmcat.rev mcat_Name"
set revmcat = server.createob ject("ADODB.Con nection")
revmcat.open = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
Server.MapPath( "/database.mdb")
set REV_mcat=revmca t.execute(SQLRE VMCAT)
%>

<% do while not REV_mcat.eof %>
<option<% if REV_mcat(0) = checkmcat then
response.write( " SELECTED")
else
response.write( "")
end if %> value="<%= REV_mcat(0) %>">- <%= REV_mcat(1) %></option> <%REV_mcat.move next
loop%>
<% revmcat.close %>
</select>

revmcat_ID [ REV_mcat(0) ] is a long integer AutoNumber in the Access 2000
database & is the tables Primary Key.
I've come across this before on another project I was fiddling with, in the end I just completly change the entire database / code to work around the
problem. I can't see away round it this time though.

I guess that it is probably something obvious, or a rule I don't know of.
I've just been staring at it for so long, I'm suffering code blindness.

Thanks.

Chris

Jul 19 '05 #3
Thank-you both very much for your suggestions!
Both CInt() and Clng() worked a treat!

I'm much obliged.

Chris

"Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message
news:Oo******** *****@tk2msftng p13.phx.gbl...
try using a convert to ensure the same datatype for comparison CStr() or
CInt()
--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Chris Tilley - HPC:Factor" <ch************ ***@hpcfactor.c om> wrote in
message news:OD******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

I'm utterly confounded by this one. There must be some sort of rule

that
I don't know of. I'd consider myself a Newbie+1, so be gentle.

I have a database connection (working A-Ok) and a Query String value from

a
form (passed using GET & working Ok). The server is IIS5.

What I'm trying to do is get a simple IF statement to work accross the
two
numeric values. Once from a database and one from a Query String.

If %Database value% = %query string value% then
response.write( "something" )
else
response.write( "nothing")
end if

...but it's not working. It always without fail responds with "nothing".
If I response.write the database variable and the query strings the
values
are all numeric and there is always going to be a match. There are only 3
records in the database and 3 options on the form.

If I change it to %Database value%=%Databas e value% then it works,
specifying "something" on all the results. If I manually place a numeric
value into the code in place of %Query string value% it works as it
should
do, except that of course it's static.

Here is the entire code segment:

<%
checkmcat=Reque st.Querystring( "mstrcat")
SQLREVMCAT="SEL ECT TBL_revmcat.rev mcat_ID, TBL_revmcat.rev mcat_Name FROM
TBL_revmcat ORDER BY TBL_revmcat.rev mcat_Name"
set revmcat = server.createob ject("ADODB.Con nection")
revmcat.open = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
Server.MapPath( "/database.mdb")
set REV_mcat=revmca t.execute(SQLRE VMCAT)
%>

<% do while not REV_mcat.eof %>
<option<% if REV_mcat(0) = checkmcat then
response.write( " SELECTED")
else
response.write( "")
end if %> value="<%= REV_mcat(0) %>">- <%= REV_mcat(1)

%></option>
<%REV_mcat.move next
loop%>
<% revmcat.close %>
</select>

revmcat_ID [ REV_mcat(0) ] is a long integer AutoNumber in the Access
2000
database & is the tables Primary Key.
I've come across this before on another project I was fiddling with, in

the
end I just completly change the entire database / code to work around the
problem. I can't see away round it this time though.

I guess that it is probably something obvious, or a rule I don't know of.
I've just been staring at it for so long, I'm suffering code blindness.

Thanks.

Chris


Jul 19 '05 #4

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

Similar topics

9
4394
by: LRW | last post by:
I'm not exactly sure how to even ask the question, and I know my terminology is not good as I'm a SQL beginner, but, here goes. I need to find a way to make an if statement within an array...or, the "while" portion of a recordset. The best way I can ask is show what I mean. http://oscarguy.mechphisto.net/awardbrowse.php If you go there and select an award (like Best Picture), leave the year field alone, and select YES and submit,...
9
10896
by: Scott Beavers | last post by:
I'm trying to create a form in Excel to sort from the form and take the data to another worksheet. I am very new to this and any help would be appreciated. I have a value in a cell that will direct what sheet I want the cells copied to, so I thought I could use an If statement but have been unable to right the code properly, ie... If "f2" = 1 Then Sheets("XX1").Select
6
2264
by: JS | last post by:
In this sample code: if(n==0&&args>1){ for(i=num;args>i+1;i++){ s.length = 0; opt = document.createElement('OPTION'); s.appendChild(opt); opt.value = ""; opt.text = "\74-- Vælg --"; }
35
2719
by: David Cleaver | last post by:
Hello all, I was wondering if there were some sort of limitations on the "if" statement? I'm writing a program which needs to check a bunch of conditions all at the same time (basically). And I'm pretty sure the rest of the program is working just fine. The only thing I could think might be wrong is that the if statement can only hold so many values in itself? Let me show what I'm doing: if (table001]>>5]&b&0x1f] != 0 &&
32
2347
by: Stephen | last post by:
Is there a standard way to remove the warning that a C compiler might produce from the statement: if (a = b) {} I don't want to do: if ((a = b) != 0) {} Because my "a = b" is actually contained in a macro that might be used
12
20683
by: John | last post by:
I can't get my head around this! I have the following code: <% .... Code for connection to the database ... .... Code for retrieving recordset ... If Not rs.EOF Then ... Do something...
2
2072
by: marsarden | last post by:
write code like: int main(void) { int a=10; if(a<20) {} } Compiler ok on dev-cpp . don't we have to add a ";" after if
6
2250
by: vl106 | last post by:
A static code analysis tool gave me a warning on if (ptr && ptr->data) { ... } I assumed the tool doesn't get the "short circuit behaviour" in the if statement. But a collegue said it may be the missing check ot ptr against NULL.
9
2853
by: chutsu | last post by:
hi I got a simple program, and I was wondering how do you check if the string in an array = a string. For example if I put "APPLE" in array Array then how can I check it with a if statement. if (Array == 'APPLE'){ do something; } or do I need to use a different method to check?
0
8683
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
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
9031
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
8902
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
8873
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
5862
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
4372
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...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
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.