CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 [RESOLVED] CCDLookup

Print topic Send  topic

Author Message
Chris__T


Posts: 339
Posted: 08/08/2008, 12:54 PM

I want to check the address (Job_Site) against a different database to see if it's in there. If so, it gives the msgbox in the if-then below:

dim ccs_result  
  
ccs_result = CCDLookup("swo_jobsite", "Stop_Work_Orders", "swo_jobsite=" & Permit.Job_Site.value, DBpermit)  
  
if (ccs_result) then  
	Msgbox "Warning! This address has a stop work order."  
end if


I'm doing this from a record-submitting page. So the user types in all the info that they are going to submit to the database, hit "Add" button, and I put this code in On Click event for the button. So it checks the Job_Site value from the textbox and checks it against the swo_jobsite value in the CCDLookup.

But when you click the button, it goes to a white screen, not completing anything.
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/08/2008, 3:07 PM

First off, I would suggest on validate not onclick
secondly
I assume you have 2 cnnections defined in Project Connections, if not you should.
Only one cnnection is default opened()at leat that is what I think......
As I am into PhP I would
$DBPermit->open();
CCDLookup(.......)
... Some errorsetting if wrong
$DBPermit->close();

anyway I would sugest to see if connection is opene and closed.


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/08/2008, 3:07 PM

Double posted

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
davidwoo

Posts: 53
Posted: 08/08/2008, 6:53 PM

check this out : http://classicasp.aspfaq.com/general/how-do-i-send-a-ms...x-from-asp.html
View profile  Send private message
Chris__T


Posts: 339
Posted: 08/11/2008, 8:10 AM

Quote wkempees:
First off, I would suggest on validate not onclick
secondly
I assume you have 2 cnnections defined in Project Connections, if not you should.
Only one cnnection is default opened()at leat that is what I think......
As I am into PhP I would
$DBPermit->open();
CCDLookup(.......)
... Some errorsetting if wrong
$DBPermit->close();

anyway I would sugest to see if connection is opene and closed.



Is that the "On Validate" for the page? And when does "on validate" trigger? before I submit to the db?

View profile  Send private message
Chris__T


Posts: 339
Posted: 08/11/2008, 8:12 AM

Quote davidwoo:

Thanks davidwoo. I will have to look into those examples. I guess the code would be stuck in the on click (or on validate, like walter said)
View profile  Send private message
Oper


Posts: 1195
Posted: 08/11/2008, 2:54 PM

Validate submit before the databse is Added.

Chris for a quick test:

create a label anywhere (set Property as HTML

then

just
Label1.value="<script language=""JavaScript"" type=""text/javascript"">alert('OMG an ERROR');</script>"

Do this a let me know if worked for you.

btw: msgbox just worn under VBScript not under ASP.
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
Chris__T


Posts: 339
Posted: 08/12/2008, 6:31 AM

Quote Oper:
Validate submit before the databse is Added.

Chris for a quick test:

create a label anywhere (set Property as HTML

then

just
Label1.value="<script language=""JavaScript"" type=""text/javascript"">alert('OMG an ERROR');</script>"

Do this a let me know if worked for you.

btw: msgbox just worn under VBScript not under ASP.

Ok, I created the label, and stuck that code in the label's BEFORE SHOW event. It worked, and brought up the alert
View profile  Send private message
Chris__T


Posts: 339
Posted: 08/12/2008, 6:57 AM

I think I'm having a problem with my CCDLookup.

  
dim ccs_result  
  
ccs_result = CCDLookup("swo_jobsite", "Stop_Work_Orders", "swo_jobsite=" & Permit.Job_Site.value, DBpermit)  

I just stuck that in the on validate event for the page, with no error checking or any other statements, and it won't even work after i click the button. Gives a blank white page.

Walter: how come I just can't use the default connection? CCDLookup likes to use its own dedicated connection?

EDIT: doh! It would really help if I spelled the connection the right way.... it's permits, not permit :-O

It looks like the ccdlookup worked, so i'll go back and try the alerts that oper showe me.
View profile  Send private message
Chris__T


Posts: 339
Posted: 08/12/2008, 7:37 AM

  
dim ccs_result  
  
  
ccs_result = CCDLookup("swo_jobsite", "Stop_Work_Orders", "swo_jobsite=" & Permit.Job_Site.value, DBpermits)  
  
if (ccs_result) then  
    Response.Redirect("http://www.google.com")  
end if  

That would seem like a simple test to see if it worked. I stuck this in OnValidate for the page, and after I hit the submit button, it just sends the info to the db, and returns to the form submittal page (default in Return Page property)

And I used a jobsite address I know for sure is in the stop_work_orders db

I had also put this in the onclick event for the submit button, but that didn't work either.
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/12/2008, 10:18 AM

response.write(ccs_result)
(check the syntax!)
should show you what is returned from the ccdlookup().

My statement about opening was based on the fact that you wrote you were checking against another databsase.
Quote :
I want to check the address (Job_Site) against a different database

Walter
Not ASP!

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
Oper


Posts: 1195
Posted: 08/12/2008, 12:29 PM

Chrish may be a odd question but, are you sure thre is not reponse.end?


also

put some debug like

response.write "I'm HERE (A)<br>"

ccs_result=...........

response.write "I'm HERE (B)<br>"

.
.
.

response.write "I'm HERE (C)<br>"


etc.

also did you view source the the empty page that poped?

also chist could you copy paste the full Validation function
from the very begining?



_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
Chris__T


Posts: 339
Posted: 08/12/2008, 1:12 PM

tried the response.write(ccs_result). Doesn't bring anything up, but then I could be using it in the wrong spot. I don't know where I should put it so I can see what it's trying to process.

I tried a 2nd connection to be used for the CCDLookup() but it didn't like it (white blank screen)

Initially, when I started this project, a person put the address in the Job_site field on the form, and there was a javascript button next to it. It was pressed, and a new window popped up with a grid that ran SQL query in this 2nd database against the address in Job_site to see if it was in there. User liked it, but wanted it to just notify when form submitted. Didn't have to show results, but just bring up an alert to let the user know it found the address in the other db. That's how I got to this point.

View profile  Send private message
Oper


Posts: 1195
Posted: 08/12/2008, 1:19 PM

Copy / paste the On validate function from the Function ...... util the end Function
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/12/2008, 1:19 PM

It's getting confusing, too much info, not enough details....... lol.
Are there 2 databases yes or no.
If yes, does your Project Settings->Connections have both connections?
Wat are the names of both connections?

My point is if you have connectionA and ConnectionB in ProjectSettings, and Permits is ConnectionB, all other pages having ConnectionA as connection, then ConnectionB is not opened. Therefore using correct ASP syntax you should
- declare a temporary connection (php: $db = clsConnectionB)
- do your CCDLookup() using that temporary connection as last parameter in it.
- after the lookup clear the temporary connection and close it.

Hope you can follow my reasoning.

Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/12/2008, 1:22 PM

Yep follow Opers request as well as answering my questions.
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
Chris__T


Posts: 339
Posted: 08/12/2008, 1:23 PM

oper: where do I put that debug stuff? in html area or code area?

Here is my OnValidate event code for the Page:
  
Function Permit_OnValidate(Sender) 'Permit_OnValidate @2-6EAEB21A  
  
'Custom Code @92-73254650  
' -------------------------  
' Write your own code here.  
' -------------------------  
'End Custom Code  
  
dim ccs_result  
  
  
ccs_result = CCDLookup("swo_jobsite", "Stop_Work_Orders", "swo_jobsite=" & Permit.Job_Site.value, DBpermits)  
  
  
if (ccs_result) then  
    Response.Redirect("http://www.google.com")  
end if  

View profile  Send private message
Chris__T


Posts: 339
Posted: 08/12/2008, 1:24 PM

Walter: Ugh, my bad. Two TABLES, not databases. I apologize
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/12/2008, 1:34 PM

I sit back now, Apol accepted.
  
Dim ccs_result  
Dim Connection  
  
Set Connection = New clsDBPermits  
Connection.Open  
  
response.write(Permit.Job_Site.value)  
ccs_result = CCDLookup("swo_jobsite", "Stop_Work_Orders", "swo_jobsite=" & Permit.Job_Site.value, Connection)    
  
response.write(ccs_result)  
  
Connection.Close  
Set Connection = Nothing  
  

Just a suggestion

Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
Oper


Posts: 1195
Posted: 08/12/2008, 2:37 PM

Do this now and copy paste your screen display:

dim ccs_result
response.write "I'm HERE (A)<br>"

ccs_result = CCDLookup("swo_jobsite", "Stop_Work_Orders", "swo_jobsite=" & Permit.Job_Site.value, DBpermits)

response.write "I'm HERE (B)<br>"
response.write "------------[" & ccs_result & "[----------------------<br>"

if (ccs_result) then
response.write "I'm HERE (C)<br>"
'Response.Redirect("http://www.google.com") Comment this line please
end if

response.write "I'm HERE (D)<br>"

RESPONSE.END

waiting................
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
Chris__T


Posts: 339
Posted: 08/12/2008, 2:55 PM

Doh...I had to do a different job and just got back to my computer to see your responses.....but it's the end of the work day....I will pick this up tomorrow...thanks for your help, oper and walter.
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/12/2008, 2:55 PM

Oper,
swo_jobsite is a string
does ASP need ToSQL conversion?
he must be missing the double quotes!

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/12/2008, 2:56 PM

Ok 2morrow then.
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
Oper


Posts: 1195
Posted: 08/12/2008, 3:08 PM

ccs_result is a string then how you using as a Boolen true/false 1/0???
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
Chris__T


Posts: 339
Posted: 08/13/2008, 6:22 AM

Really appreciate your help guys.

Oper: Ok, here's the screen output from what you told me to stick in:

Quote :
I'm HERE (A)
Source: CCDLookUp function
Command Text: SELECT swo_jobsite FROM Stop_Work_Orders WHERE swo_jobsite=345 Mosley
Error description: Syntax error (missing operator) in query expression 'swo_jobsite=345 Mosley'. (Microsoft JET Database Engine)
I'm HERE (B)
------------[[----------------------
I'm HERE (D)

I stuck this in the "on validate" portion.

regarding yours and Walter's post regarding string and ccs_result: I've used ccs_result as a condition in an if/then before, and it worked. It was a slightly different setup than this problem though.
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/13/2008, 5:23 PM

Chris do you see the missing " double quotes?
  
Command Text: SELECT swo_jobsite FROM Stop_Work_Orders WHERE swo_jobsite=345 Mosley  
should be
  
Command Text: SELECT swo_jobsite FROM Stop_Work_Orders WHERE swo_jobsite="345 Mosley"  

change
  
ccs_result = CCDLookup("swo_jobsite", "Stop_Work_Orders", "swo_jobsite=" & Permit.Job_Site.value, DBpermits)   
to
  
ccs_result = CCDLookup("swo_jobsite", "Stop_Work_Orders", "swo_jobsite=" & DBpermits.ToSQL(Permit.Job_Site.value, ccsText), DBpermits)   
which will at least result in correct SQL.

About the test if (ccs_result)
In PhP that will deliver a TRUE value if ccs_result exists and is not NULL.
do not know about ASP.

What I would do is test for at least 1 record being returned.
like this:
  
ccs_result = CCDLookup("Count(*)", "Stop_Work_Orders", "swo_jobsite=" & DBpermits.ToSQL(Permit.Job_Site.value, ccsText), DBpermits)   
  
if (ccs_result <> 0)  
.......  

Walter

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
Oper


Posts: 1195
Posted: 08/13/2008, 7:41 PM

Quote Chris__T:
Really appreciate your help guys.

Oper: Ok, here's the screen output from what you told me to stick in:

Quote :
I'm HERE (A)
Source: CCDLookUp function
Command Text: SELECT swo_jobsite FROM Stop_Work_Orders WHERE swo_jobsite=345 Mosley
Error description: Syntax error (missing operator) in query expression 'swo_jobsite=345 Mosley'. (Microsoft JET Database Engine)
I'm HERE (B)
------------[[----------------------
I'm HERE (D)


you could use ccs_result (but wil work only if the return value is 1 or 0 for boolean

check Walter Sample he will count(*) how many records if there is a least 1 record then
the if will fire.

normaly is very important to use few response.write and an response.end
and the problema appear quick as you can see. (miising " )

keep in mind that ccs_result is the retunr value of the Field or Formula you use in the ccdLookup
so the return value could be a string.



I stuck this in the "on validate" portion.

regarding yours and Walter's post regarding string and ccs_result: I've used ccs_result as a condition in an if/then before, and it worked. It was a slightly different setup than this problem though.




_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
Chris__T


Posts: 339
Posted: 08/14/2008, 11:15 AM

Thank you very much!

That seemed to do the trick. I guess my mind wasn't letting me see that it was missing double quotes. I hate when that happens.

And they count(*) is a good help too. Makes using ccs_result in the if-then more "code etiquette" friendly.

Thanks Walter. Thanks Oper. Very nice when I can get a problem worked out on here. Plus I learn something each time.

I really need to donate to Walter's paypal :) Should be coming soon.... :)
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.