Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 22nd, 2005, 12:26 PM
Authorized User
 
Join Date: Jan 2005
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default No errors and no output

Having an issue with the code below. I know that the table has data in it but the debug sql statement has no errors and no data is displayed.

Here is the code...this is the whole page minus includes for cookie and sql server connection....the output will be below it.

<%

deaID=request("deaID")
region=request("region")

sql = "SELECT DISTINCT RegionCodes.zipcode FROM RegionCodes WHERE RegionName='" & region & "'"

'debugging code
Response.Write "DEBUG: SQL is " & sql & "<BR>"


set getregioncodes = conn.execute(sql)

%>


Region is a state name "Houston" for instance. deaID will be used in the next part of the page so it is irrelevant at the moment.

All I get for outpu is this.....

DEBUG: SQL is SELECT DISTINCT RegionCodes.zipcode FROM RegionCodes WHERE RegionName='Houston'
--------------------------------------------------------------------------------


no data is displayed below and no errors. Little help please.
 
Old February 22nd, 2005, 12:33 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

What are you expecting?

As far as I can see, you are not attempting to add any further output to the page and your sql looks fine.

"getregioncodes" may well be a populated recordset - check for EOF and then try and write some field content to the page if you have any records.

HTH,

Chris

 
Old February 22nd, 2005, 12:46 PM
Authorized User
 
Join Date: Jan 2005
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok your write been looking at too much code so I changed the code to the following.




<%

deaID=request("deaID")
region=request("region")

sql = "SELECT DISTINCT RegionCodes.zipcode FROM RegionCodes WHERE RegionName='" & region & "'"

'debugging code
Response.Write "DEBUG: SQL is " & sql & "<BR>"


set getregioncodes = conn.execute(sql)

Response.Write "debug recordset is " & getregioncodes & "<BR>"

and now I get this error...

Type mismatch

DealershipRegions.asp, line 17

line 17 is Response.Write "debug recordset is " & getregioncodes & "<BR>"

now what?
 
Old February 22nd, 2005, 12:54 PM
Authorized User
 
Join Date: Jan 2005
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

typo corrected the code to the following...

sql = "SELECT DISTINCT RegionCodes.zipcode FROM RegionCodes WHERE RegionName='" & region & "'"

'debugging code
Response.Write "DEBUG: SQL is " & sql & "<BR>"


set getregioncodes = conn.execute(sql)
regioncodes= getregioncodes("zipcode")
Response.Write "debug recordset is " & regioncodes & "<BR>"


and I get this output.

DEBUG: SQL is SELECT DISTINCT RegionCodes.zipcode FROM RegionCodes WHERE RegionName='Houston'
--------------------------------------------------------------------------------

debug recordset is 77001

In order to see the rest I am going to have to loop it right? so how would I set up th e debug statement to see that. Because I don't need to loop the recordset to get all the data do I?

I am eventually going to take the data from this record set and insert it into a new table with the deaID and zipcode information.

Is my thinking correct here?

 
Old February 22nd, 2005, 12:54 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

The problem is that you're trying to write a recordset object to the page and Response.Write is expecting a string.
Try something like...
Code:
If Not getregioncodes.EOF Then
    Response.Write getregioncodes("zipcode").Value
End If
Cheers,

Chris

 
Old February 22nd, 2005, 01:05 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hehe - started posting before the page updated.

Yep, your thinking is bang on - you will need a loop, try this...
Code:
Response.Write DebugRs(getregioncodes)

...

Function DebugRs(pRs)
    Dim temp: temp = ""
    If Not pRs.EOF Then 
        temp = temp & "<table>"
        Dim field
        temp = temp & "<tr>"
        For Each field In pRs.Fields
            temp = temp & "<th>" & field.Name & "</th>"
        Next
        temp = temp & "</tr>"
        Do While Not pRs.EOF
            temp = temp & "<tr>"    
            For Each field In pRs.Fields
                temp = temp & "<td><nobr>" & field.Value & "</nobr></td>"
            Next
            temp = temp & "</tr>"
            pRs.MoveNext
        Loop
        temp = temp & "</table>"
    End If    
    DebugRs = temp
End Function
HTH,

Chris
 
Old February 22nd, 2005, 01:05 PM
Authorized User
 
Join Date: Jan 2005
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok changed the code like you said...I feel stupid for not realizing that myself..like I said too much code today....it only Tuesday... anyway.

here is my output

DEBUG: SQL is SELECT RegionCodes.zipcode FROM RegionCodes WHERE RegionName='Houston'
--------------------------------------------------------------------------------

77001

I know that the table has at least 100 zipcodes with the RegionName as Houston.

So why is it only giving me one record?

I took out the Distinct part of the SQL statement to see if that was the reason...same results.

 
Old February 22nd, 2005, 01:07 PM
Authorized User
 
Join Date: Jan 2005
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

samething here started my reply without checking the post first...let me try your new reply and I 'll be bac...

 
Old February 22nd, 2005, 01:28 PM
Authorized User
 
Join Date: Jan 2005
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok this worked...just out of curiosity why did you create a function for this...

I'm fairly new to asp but I am learning..what are the advantages to the function....beside reusability

 
Old February 22nd, 2005, 01:38 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

The function was one I already had kicking around - debugging recordsets is a fairly common task, so having a function like this can be handy.

Like you say, functions are reusable which is a big bonus, they can also make your code easier to understand and reduce server overhead - variables, objects etc that you only use within a function only last as long as the function is executing.

Cheers,

Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
Errors nnrin Classic ASP Databases 2 December 11th, 2007 12:36 PM
Help with Errors Riderman BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 August 8th, 2007 09:46 AM
Can't get errors to display with <html:errors> michaeldill JSP Basics 0 August 2nd, 2004 01:47 PM
errors and fixing errors Droopy XML 0 August 26th, 2003 12:47 AM
Errors Errors DB Errors Ljhopkins VS.NET 2002/2003 0 July 15th, 2003 12:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.