Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Complex SQL Query issue


Message #1 by "Virgil Carroll" <vcarroll@i...> on Wed, 7 Aug 2002 08:13:47 -0500
Group,

I was hoping someone might know the answer to this question.  In Classic 
ASP a person could have a additional part of a SQL statement (to an 
access 2000 database) like this.

SQL =3D SQL & " AND (CDbl(prodPrice) BETWEEN " & CDbl(PriceStart) & " 
AND " & CDbl(PriceEnd) & " or (prodSaleIsActive=3D1 and 
CDbl(prodSalePrice) BETWEEN " & CDbl(PriceStart) & " AND " & 
CDbl(PriceEnd) & ")) "

Thus changine these fields, which are text fields, to numeric on the fly 
while doing the query.  In ASP.NET, when I simulate the same thing it 
does not work.  Instead I get an error staing that there is improper 
formatting.

This is my code for ASP.NET

storelist.qryCapture+=3D"AND CDbl(prodPrice) BETWEEN " + CDbl(priceFrom) 
+ " AND " + CDbl(priceTo) + " OR (prodSaleIsActive=3D1 AND 
CDbl(prodSalePrice) BETWEEN'" + CDbl(priceFrom) + " AND '" + 
CDbl(priceTo) + ") "

I am guessing this has something to do with the exactness of code as it 
has to be in .NET.  Compared with Classic where you could cheat a lot.

If anyone has any ideas.  I would greatly appreciate any help.

Tx,
Virgil Carroll
President/CEO
IStream Interactive
2013 2nd Avenue North, Suite B-4
Anoka, MN 55303
(xxx) xxx-xxxx
vcarroll@i...
www.istreaminteractive.com
Message #2 by Immanuel_L'heureux@C... on Wed, 7 Aug 2002 13:08:06 -0700
I think the problem is that in classic asp it allows string concatenation 
such as
stringvar = stringvar + intvar + stringvar

since there is very loose typing.  Can't do this in asp.net.  You need to 
construct a string, so all substrings must be of type string.
Keep in mind, the goal is to construct a SQL string.

So you should have stringvar += stringvar + 
System.Convert.ToString(priceForm) + " and " + 
System.Convert.ToString(priceTo) + " Or " ... etc

- Immanuel L'Heureux





"Virgil Carroll" <vcarroll@i...>
08/07/2002 06:13 AM
Please respond to ASP+

 
        To:     ASP+ <aspx@p...>
        cc: 
        Subject:        [aspx] Complex SQL Query issue


Group,

I was hoping someone might know the answer to this question.  In Classic 
ASP a person could have a additional part of a SQL statement (to an access 
2000 database) like this.

SQL = SQL & " AND (CDbl(prodPrice) BETWEEN " & CDbl(PriceStart) & " AND " 
& CDbl(PriceEnd) & " or (prodSaleIsActive=1 and CDbl(prodSalePrice) 
BETWEEN " & CDbl(PriceStart) & " AND " & CDbl(PriceEnd) & ")) "

Thus changine these fields, which are text fields, to numeric on the fly 
while doing the query.  In ASP.NET, when I simulate the same thing it does 
not work.  Instead I get an error staing that there is improper 
formatting.

This is my code for ASP.NET

storelist.qryCapture+="AND CDbl(prodPrice) BETWEEN " + CDbl(priceFrom) + " 
AND " + CDbl(priceTo) + " OR (prodSaleIsActive=1 AND CDbl(prodSalePrice) 
BETWEEN'" + CDbl(priceFrom) + " AND '" + CDbl(priceTo) + ") "

I am guessing this has something to do with the exactness of code as it 
has to be in .NET.  Compared with Classic where you could cheat a lot.

If anyone has any ideas.  I would greatly appreciate any help.

Tx,
Virgil Carroll
President/CEO
IStream Interactive
2013 2nd Avenue North, Suite B-4
Anoka, MN 55303
(xxx) xxx-xxxx
vcarroll@i...
www.istreaminteractive.com





Message #3 by "Carole D. Sullivan" <carolesullivan@e...> on Fri, 9 Aug 2002 01:27:31
Isn't progress wonderful?  This worked for me.

Dim funcSequence As Integer = System.Int32.Parse(txtFunctionSequence.Text)

> I think the problem is that in classic asp it allows string 
concatenation 
such as
stringvar = stringvar + intvar + stringvar

since there is very loose typing.  Can't do this in asp.net.  You need to 
construct a string, so all substrings must be of type string.
Keep in mind, the goal is to construct a SQL string.

So you should have stringvar += stringvar + 
System.Convert.ToString(priceForm) + " and " + 
System.Convert.ToString(priceTo) + " Or " ... etc

- Immanuel L'Heureux





"Virgil Carroll" <vcarroll@i...>
08/07/2002 06:13 AM
Please respond to ASP+

 
        To:     ASP+ <aspx@p...>
        cc: 
        Subject:        [aspx] Complex SQL Query issue


Group,

I was hoping someone might know the answer to this question.  In Classic 
ASP a person could have a additional part of a SQL statement (to an access 
2000 database) like this.

SQL = SQL & " AND (CDbl(prodPrice) BETWEEN " & CDbl(PriceStart) & " AND " 
& CDbl(PriceEnd) & " or (prodSaleIsActive=1 and CDbl(prodSalePrice) 
BETWEEN " & CDbl(PriceStart) & " AND " & CDbl(PriceEnd) & ")) "

Thus changine these fields, which are text fields, to numeric on the fly 
while doing the query.  In ASP.NET, when I simulate the same thing it does 
not work.  Instead I get an error staing that there is improper 
formatting.

This is my code for ASP.NET

storelist.qryCapture+="AND CDbl(prodPrice) BETWEEN " + CDbl(priceFrom) + " 
AND " + CDbl(priceTo) + " OR (prodSaleIsActive=1 AND CDbl(prodSalePrice) 
BETWEEN'" + CDbl(priceFrom) + " AND '" + CDbl(priceTo) + ") "

I am guessing this has something to do with the exactness of code as it 
has to be in .NET.  Compared with Classic where you could cheat a lot.

If anyone has any ideas.  I would greatly appreciate any help.

Tx,
Virgil Carroll
President/CEO
IStream Interactive
2013 2nd Avenue North, Suite B-4
Anoka, MN 55303
(xxx) xxx-xxxx
vcarroll@i...
www.istreaminteractive.com






  Return to Index