By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,997 Members | 1,470 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,997 IT Pros & Developers. It's quick & easy.

How do find a empty field/value/records?

P: n/a
I know it should be very easy but I am new in ASP so I could not
figured out.
Here is the simplified version of my code:

thePaymentID= request.querystring("IDValue")

SQLqueryPayment= "SELECT sum(paid) as paid, sum(Interest) as interest
FROM payment WHERE payment_ID =" & thePaymentID & ""

dim rstempPayment
set conntemp=server.createobject("adodb.connection")
conntemp.Open "DSN=payment"

set rstempPayment=conntemp.execute(SQLqueryPayment)
fldValPaid = rstempOwner.Fields("paid").Value
------------------------------------------------------------------------
I need to find out if "fldValPaid" hold anything. I will use it an
IF ELSE statement. In payment table a particular record could exist or
not. How do I find out by evaluating "fldValPaid" if any record
exists or not. I have to find out using "fldValPaid" ...I can not
use number of record/record return or any other method.

I hope you understand my question.
Thanks,
-Rahman

Dec 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
rahman wrote:
I know it should be very easy but I am new in ASP so I could not
figured out.
Here is the simplified version of my code:
In the future, please tell us what database type and version you are using.
It is almost always relevant.
thePaymentID= request.querystring("IDValue")

SQLqueryPayment= "SELECT sum(paid) as paid, sum(Interest) as interest
FROM payment WHERE payment_ID =" & thePaymentID & ""

dim rstempPayment
set conntemp=server.createobject("adodb.connection")
conntemp.Open "DSN=payment"
You may want to consider replacing your ODBC DSN with the native OLE DB
provider for your database:
http://www.aspfaq.com/show.asp?id=2126

set rstempPayment=conntemp.execute(SQLqueryPayment)
fldValPaid = rstempOwner.Fields("paid").Value
------------------------------------------------------------------------
I need to find out if "fldValPaid" hold anything. I will use it an
IF ELSE statement. In payment table a particular record could exist or
not. How do I find out by evaluating "fldValPaid" if any record
exists or not.


You can't. fldValPaid will always contain a value, whether any records
existed or not. What you need to do is add a third aggregate calculation to
your query to count the number of records:
.... as interest, count(*) as payments FROM ...

Then check the value of the payments field to see if it's greater than 0.

HTH,
Bob Barrows
PS. You may want to consider using parameters rather than dynamic sql. Your
application will be more secure, robust and easier to maintain:

http://groups-beta.google.com/group/...e36562fee7804e
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Dec 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.