Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 3rd, 2008, 10:39 AM
Registered User
Join Date: Jan 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default values dont show up on ASP page but exist in DB

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 & "'/>")

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!!!


Reply With Quote
  #2 (permalink)  
Old September 3rd, 2008, 01:34 PM
Friend of Wrox
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

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

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?
Reply With Quote
  #3 (permalink)  
Old September 3rd, 2008, 02:03 PM
Registered User
Join Date: Jan 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

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...

Reply With Quote

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

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

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

All times are GMT -4. The time now is 08:49 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.