Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > If statement halts page load

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-08-03, 16:39
corporate_targe corporate_targe is offline
Registered User
 
Join Date: May 2003
Posts: 18
If statement halts page load

This page loads and works fine without the If statement. When the If statement is present, it doesn't get loaded. I'm new to ASP and Access. I think i have the Access part right since, again, the page loads without the if statement. Can anyone figure out what is wrong? Thx.

<% Response.Buffer = True %>

<html>
<head>
<title>Memeber Email Listing of the chosen zip code</title>
</head>
<body>

<%
Dim rs
Set rs = Server.CreateObject ("ADODB.Recordset")

rs.Open "members", "DSN=act"

zipwanted = Request.Querystring("zipwanted")

While Not rs.EOF
If rs("zip") = request.querystring("zipwanted") Then
Response.Write "Email : " & rs("email") & "<br>"
Response.Write "Skills : " & rs("skills") & "<br>"
Response.Write "Zip Code : " & rs("zip") & "<br>"
Response.Write "<br>"
rs.MoveNext
End If
Wend

rs.Close
Set rs = Nothing
%>

</body>
</html>
Reply With Quote
  #2 (permalink)  
Old 05-08-03, 16:45
corporate_targe corporate_targe is offline
Registered User
 
Join Date: May 2003
Posts: 18
sorry, i've recently moved the End If to where it should be, before the rs.MoveNext statement.

Now the problem is that records with the asked for zip don't show up. When i change the if statement from "=" to "<>", it prints the record, even though the record contains the zip that was asked for.

Thx again.
Reply With Quote
  #3 (permalink)  
Old 05-09-03, 11:55
MrWizard MrWizard is offline
Registered User
 
Join Date: Mar 2003
Location: Atlanta, GA
Posts: 191
Dear CT...

I'm not an expert on data types, but my first inclination is that data types are perhaps part of your issue... because even though the data looks like it should match, it isn't matching.

I would go about what you're apparently trying to do a bit differently, but for starters, why don't you just try changing things as follows:

Code:
Dim rs Set rs = Server.CreateObject ("ADODB.Recordset") rs.Open "members", "DSN=act" zipwanted = CStr(Request.Querystring("zipwanted")) While Not rs.EOF If rs("zip") = zipwanted Then Response.Write "Email : " & rs("email") & "<br>" Response.Write "Skills : " & rs("skills") & "<br>" Response.Write "Zip Code : " & rs("zip") & "<br>" Response.Write "<br>" End If rs.MoveNext Wend rs.Close Set rs = Nothing

Personally, I would use SQL to filter the recordset first...

Code:
zw = CStr(Request.Querystring("zipwanted")) SQLx="SELECT * FROM members WHERE zip='" & zw & "'" Set rs = Server.CreateObject("ADODB.Recordset") rs.Open SQLx, "DSN=act" While Not rs.EOF Response.Write "Email : " & rs("email") & "<br>" Response.Write "Skills : " & rs("skills") & "<br>" Response.Write "Zip Code : " & rs("zip") & "<br>" Response.Write "<br>" rs.MoveNext Wend rs.Close Set rs = Nothing

Good Luck....

Tim
__________________
Tim
Reply With Quote
  #4 (permalink)  
Old 05-09-03, 19:10
corporate_targe corporate_targe is offline
Registered User
 
Join Date: May 2003
Posts: 18
Thx Tim.

Perhaps my configurationg is wrong somewher, because your code gave this error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/RH25/listings.asp, line 59

line 59 is: rs.Open SQLx, "DSN=act"

What needs to be done to fix that?

Thx again.
Reply With Quote
  #5 (permalink)  
Old 05-09-03, 19:32
MrWizard MrWizard is offline
Registered User
 
Join Date: Mar 2003
Location: Atlanta, GA
Posts: 191
Quote:
Originally posted by corporate_targe
Thx Tim.

Perhaps my configurationg is wrong somewher, because your code gave this error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/RH25/listings.asp, line 59

line 59 is: rs.Open SQLx, "DSN=act"

What needs to be done to fix that?

Thx again.


Sorry, in my haste I assumed you had a connection object set up, and just copied and pasted what you had without really thinking...

zw = CStr(Request.Querystring("zipwanted"))
SQLx="SELECT * FROM members WHERE zip='" & zw & "'"
adoConn="DSN=act"
Set Q = Server.CreateObject("ADODB.Connection")
Q.Open adoConn
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open SQLx, Q
... and then the rest of it...

should do it I think.

Tim
__________________
Tim
Reply With Quote
  #6 (permalink)  
Old 05-09-03, 19:34
MrWizard MrWizard is offline
Registered User
 
Join Date: Mar 2003
Location: Atlanta, GA
Posts: 191
I'm also assuming you have the DSN called 'act' set up on the server?

Tim

Quote:
Originally posted by corporate_targe
Thx Tim.

Perhaps my configurationg is wrong somewher, because your code gave this error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/RH25/listings.asp, line 59

line 59 is: rs.Open SQLx, "DSN=act"

What needs to be done to fix that?

Thx again.
__________________
Tim
Reply With Quote
  #7 (permalink)  
Old 05-10-03, 00:21
corporate_targe corporate_targe is offline
Registered User
 
Join Date: May 2003
Posts: 18
yes
Reply With Quote
  #8 (permalink)  
Old 05-10-03, 02:14
MrWizard MrWizard is offline
Registered User
 
Join Date: Mar 2003
Location: Atlanta, GA
Posts: 191
Quote:
Originally posted by corporate_targe
yes


did you set up the connection object per my previous post?
__________________
Tim
Reply With Quote
  #9 (permalink)  
Old 05-11-03, 00:54
corporate_targe corporate_targe is offline
Registered User
 
Join Date: May 2003
Posts: 18
no, i had it set up and was able to print the contents of the database except when the if statement that checked rs("zip") against the zip entered was left out.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On