Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 September 3rd, 2008, 10:39 AM
Registered User
 
Join Date: Jan 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default values dont show up on ASP page but exist in DB

hi,
i am a newbie to asp and facing a weird problem.
All i am trying to display is few fields on the page from the database (SQL Server 2005) and SOME of the values do not show on the page even though they exist in the database.

    strSQL = "SELECT * from tblCampaign;"
    Set rs = Server.CreateObject("ADODB.Recordset")
    Set rs = conDB.Execute(strSQL)

However, I found that if you write the values into a hidden variable like in the following code:

for each x in rs.fields
  response.write("<input type='hidden' name='test" & x.name & "'
                  value='" & x.value & "'/>")
next

the values start showing up. But it is not the right way of doing it and is there a reason why this is happening. Please HELP!!!

Thanks...

 
Old September 3rd, 2008, 01:34 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

So show your *REAL* code. The stuff that does NOT work. It's pointless to ask us a question about code that *does* work.

I can suggest a few possible causes of your problem, but there's no point until I see real code.

No...I will give you one *possible* hint right now. Just in case. But don't be surprised if it's irrelevant.

(1) Only SELECT the fields you actually need (in your SQL); don't use SELECT *

(2) Make sure you SELECT any TEXT or NTEXT fields *LAST*, after all the other types of fields.

(3) Make sure you assign the value of any TEXT or NTEXT field to a variable only *ONCE*, and then if you need to test or use the value multiple times, test/use the variable, not the RS("xxx") value.

In other words:

<%
Set RS = conn.Execute("SELECT numfield, datefield, NTEXTfield FROM table")
Do Until RS.EOF
    numval = RS("numfield")
    dateval = RS("datefield")
    textval = RS("NTEXTfield")
    If InStr( textval, "zamboni" ) Then
         Response.Write textval
    End If
    RS.MoveNext
Loop
%>

You see it? Under *some* circumstances, getting a long text field from the RS can then "hide" other values in the same record. And in any case, getting a long text field more than once can be problematic. Copying *ALL* values from the RS to local variables will, in general, only HELP performance anyway, so why not do it?
 
Old September 3rd, 2008, 02:03 PM
Registered User
 
Join Date: Jan 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

please pardon my brief posting and my dumb explanation, but you hit it right on the head.

The application I have been working had an access database and I am trying to convert it to SQL server. In that process, I had all the memo fields converted to varchar(MAX). After you mentioned in the post about long text, I scanned through the database and realized that this was causing the problem and changed those fields to varchar(5000).

Now everything is starting to work again and if not for your valuable input, my brain would never have caught that.

Thanks again...






Similar Threads
Thread Thread Starter Forum Replies Last Post
database dont exist zachatcoza All Other Wrox Books 2 July 31st, 2007 02:44 PM
Document design mode image dont show in IE7 h2c357 Javascript 0 May 3rd, 2007 09:21 AM
passing values from ASP page to a popup ASP Page astrosmurfboy Classic ASP Basics 3 April 21st, 2004 08:17 PM
Want to show Records on ASP Page randomly pkdev Classic ASP Databases 3 July 28th, 2003 03:20 AM





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