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 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. 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 Professional 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 30th, 2005, 02:32 PM
Authorized User
 
Join Date: Jun 2005
Location: HSP, , .
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default Display text data in textarea from SQL query

Hello All,

I am trying to display some text into textarea from an SQL query. It is a website where if a user wants to edit his profile info, the textarea will display his current description and he/she can edit it and update. Right now if a user goes to the edit page, it shows a blank textarea and the user has to type in the whole info even if they have already filled it in when they registered. I am using SQL query to retrieve the values from SQL server 2000. The query returns all the results fine when I run it in query analyzer. Here is how I try to display the text into textarea.

************************************************** ****************

<textarea name="AboutYou" maxlength="1500" cols="45" rows="7" class="Input-Error">
<%
MsgBody = Replace(TRIM(ORs("AboutYourself")), "<br>", CHR(13))
Response.write RTrim(MsgBody)
%>

</textarea>
************************************

I will be really thankfull to you all.


Reply With Quote
  #2 (permalink)  
Old November 30th, 2005, 03:09 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

What happens when you write the results outside a textarea and without the replace stuff? Do you get any results?

And are you querying other columns that do have results?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #3 (permalink)  
Old November 30th, 2005, 03:40 PM
Authorized User
 
Join Date: Jun 2005
Location: HSP, , .
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Imar,

If I write the result out of a textarea, i.e. display directly on webpage without replace, It displays the results perfectly fine. I have even tried to display it in textarea using <%=ORs("AboutYourself")%> but it does not display anything. All I get is a blank textarea.

Yes I am querying other columns as well. I have a stored procedure that populates the results from various columns.

Thanks,
Palvin


Reply With Quote
  #4 (permalink)  
Old November 30th, 2005, 03:47 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

In that case, run the original page again and looking at the resulting HTML in the browser. What do you see between the textarea tags? Does your text contain HTML tags?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #5 (permalink)  
Old November 30th, 2005, 03:55 PM
Authorized User
 
Join Date: Jun 2005
Location: HSP, , .
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Imar,

There is nothing in the resulting HTML code in browser between textarea tags. The text does not contain any html.

Palvin


Quote:
quote:Originally posted by Imar
 In that case, run the original page again and looking at the resulting HTML in the browser. What do you see between the textarea tags? Does your text contain HTML tags?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #6 (permalink)  
Old November 30th, 2005, 03:57 PM
Authorized User
 
Join Date: Jun 2005
Location: HSP, , .
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just want to let you know that even if I run the store procedure using query analyzer, it returns all the correct values.

Palvin

Quote:
quote:Originally posted by palvin
 Hello Imar,

There is nothing in the resulting HTML code in browser between textarea tags. The text does not contain any html.

Palvin


Quote:
quote:Originally posted by Imar
 In that case, run the original page again and looking at the resulting HTML in the browser. What do you see between the textarea tags? Does your text contain HTML tags?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #7 (permalink)  
Old November 30th, 2005, 04:11 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

So you're saying that this works:

<%=ORs("AboutYourself")%>

but this doesn't:

<textarea>
<%=ORs("AboutYourself")%>
</textarea>

I find that hard to believe. Can you post your code?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #8 (permalink)  
Old November 30th, 2005, 04:33 PM
Authorized User
 
Join Date: Jun 2005
Location: HSP, , .
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, Thats exactly what is happening.

Here is the code for the page. I have highlighted the textarea code in red for your convinience.



<%
SID=Request("SID")
UID=Request("UID")

    Set conn = Server.CreateObject("ADODB.Connection")
    conn.open "DSN=dsnname; uid=user; pwd=password"
    msSQL = "Execute sproc_EditProfile_CoupleOrNot '" & UID & "'"
    set ORs = conn.execute (msSQL)

    IF ORs("GenderID")=4 THEN
        Response.Redirect "editmatch_couple.asp?SID=" & SID & "&UID=" & UID
    ELSEIF ORs("GenderID")=5 THEN
        Response.Redirect "editmatch_other.asp?SID=" & SID & "&UID=" & UID
    END IF

    Set ORs = Nothing
    Conn.close

ErrorFound=Request("ErrorFound")

AttentionErr1=Request("AttentionErr1")
AttentionErr2=Request("AttentionErr2")

AboutYouErr3=Request("AboutYouErr3")
AboutYouErr4=Request("AboutYouErr4")

AboutMatchErr5=Request("AboutMatchErr5")
AboutMatchErr6=Request("AboutMatchErr6")

GenderErr7=Request("GenderErr7")

RelationshipErr8=Request("RelationshipErr8")
%>
<% SecurityCheckUID() %>
<html>
<head>
<title><% sitename() %> - Profile Edit!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="/stylesheet.css" type="text/css">
<BODY class="PageBackground" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<script language="JavaScript">
<!--
    function check_form()
    {
        if (document.form1.AboutYou.value.length > 1500)
            {
            alert("The About You Section is too long.");
            document.form1.AboutYou.focus();
            return false;
            }
        if (document.form1.AboutYou.value.length < 50)
            {
            alert("The About You Section is not long enough.");
            document.form1.AboutYou.focus();
            return false;
            }
        if (document.form1.AboutMatch.value.length > 1500)
            {
            alert("The About Your Match Section is too long.");
            document.form1.AboutMatch.focus();
            return false;
            }
        if (document.form1.AboutMatch.value.length < 50)
            {
            alert("The About Your Match Section is not long enough.");
            document.form1.AboutMatch.focus();
            return false;
            }
    }
// -->
</script>
<div align="center">
  <table width="750" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td align="center" valign="top">
        <table width="750" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align="center">
              <% printLOGO()%>
            </td>
          </tr>
          <tr>
            <td align="center" height="35">
              <table width="100%" border="0" cellspacing="1" cellpadding="1">
                <tr>
                  <td align="left" valign="top" width="150">
                    <% Menu()%>
                  </td>
                  <td align="right">
                    <table width="100%" border="0" cellspacing="1" cellpadding="1" bordercolor="#000000">
                      <tr bgcolor="#F7F7F7" align="center">
                        <td class="Font-Small-Bold-Black">
                          <table width="100%" border="0" cellspacing="1" cellpadding="1">
                            <tr bgcolor="#F7F7F0">
                              <td width="5%"><b><img src="../images/profileicon.gif" width="84" height="44"></b></td>
                              <td width="95%" bgcolor="#F7F7F0" align="left"><span class="Headline-Bold">Edit
                                : About Your Match!</span><br>
                                <span class="Font-Reg-Black">Make the changes
                                to the fields provided below, and click the button
                                when you are ready to make the changes!<br>
                                These changes take effect directly after submitting
                                them. </span></td>
                            </tr>
                          </table>
                        </td>
                      </tr>
                      <tr bgcolor="#F7F7F7" align="center">
                        <td bgcolor="#F7F7F7" valign="top"><br>
                          <table width="590" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td bgcolor="#3399CC">
                                <table width="100%" border="0" cellspacing="1" cellpadding="1">
                                  <tr>
                                    <td bgcolor="#FFFFFF" align="center">
                                      <table width="580" border="0" cellspacing="0" cellpadding="0">
                                        <tr align="left">
                                          <td colspan="3" valign="bottom"><img src="/new/images/container_01.gif" width="580" height="17"></td>
                                        </tr>
                                        <tr>
                                          <td align="left" valign="top" background="/new/images/container_02.gif"><img src="/new/images/container_02.gif" width="4" height="10"></td>
                                          <td width="572" align="center">
                                            <form name="form1" method="post" action="editmatch_proc.asp?SID=<%=SID%>&UID=<%=UID %>" onSubmit="return check_form()">
                                              <%
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.open "DSN=dsnname; uid=user; pwd=password"
    msSQL = "Execute sproc_EditProfile_Match '" & UID & "'"
    SET ORs = conn.Execute (msSQL)

//Attention Header Declaration
    Attention=Request("Attention")
        IF Attention="" OR Attention=NULL THEN
            Attention=ORs("AttentionHeader")
        END IF

//Seeking Gender Declarations
    Gender1=Request("Gender1")
        IF Gender1="" OR Gender1=NULL THEN
            Gender1=ORs("Gender_Male")
        ELSEIF Gender1=1 THEN
            Gender1=TRUE
        END IF
    Gender2=Request("Gender2")
        IF Gender2="" OR Gender2=NULL THEN
            Gender2=ORs("Gender_Female")
        ELSEIF Gender2=1 THEN
            Gender2=TRUE
        END IF
    Gender3=Request("Gender3")
        IF Gender3="" OR Gender3=NULL THEN
            Gender3=ORs("Gender_Couple")
        ELSEIF Gender3=1 THEN
            Gender3=TRUE
        END IF
    Gender4=Request("Gender4")
        IF Gender4="" OR Gender4=NULL THEN
            Gender4=ORs("Gender_Other")
        ELSEIF Gender4=1 THEN
            Gender4=TRUE
        END IF

//Seeking Relationship Declarations
    Relationship1=Request("Relationship1")
        IF Relationship1="" OR Relationship1=NULL THEN
            Relationship1=ORs("Rel_friendship")
        ELSEIF Relationship1=1 THEN
            Relationship1=TRUE
        END IF
    Relationship2=Request("Relationship2")
        IF Relationship2="" OR Relationship2=NULL THEN
            Relationship2=ORs("Rel_email")
        ELSEIF Relationship2=1 THEN
            Relationship2=TRUE
        END IF
    Relationship3=Request("Relationship3")
        IF Relationship3="" OR Relationship3=NULL THEN
            Relationship3=ORs("Rel_Commitment")
        ELSEIF Relationship3=1 THEN
            Relationship3=TRUE
        END IF
    Relationship4=Request("Relationship4")
        IF Relationship4="" OR Relationship4=NULL THEN
            Relationship4=ORs("Rel_Dating")
        ELSEIF Relationship4=1 THEN
            Relationship4=TRUE
        END IF
    Relationship5=Request("Relationship5")
        IF Relationship5="" OR Relationship5=NULL THEN
            Relationship5=ORs("Rel_BDSM")
        ELSEIF Relationship5=1 THEN
            Relationship5=TRUE
        END IF
    Relationship6=Request("Relationship6")
        IF Relationship6="" OR Relationship6=NULL THEN
            Relationship6=ORs("Rel_Marriage")
        ELSEIF Relationship6=1 THEN
            Relationship6=TRUE
        END IF
    Relationship7=Request("Relationship7")
        IF Relationship7="" OR Relationship7=NULL THEN
            Relationship7=ORs("Rel_Swinging")
        ELSEIF Relationship7=1 THEN
            Relationship7=TRUE
        END IF
    Relationship8=Request("Relationship8")
        IF Relationship8="" OR Relationship8=NULL THEN
            Relationship8=ORs("Rel_CasSex")
        ELSEIF Relationship8=1 THEN
            Relationship8=TRUE
        END IF
    Relationship9=Request("Relationship9")
        IF Relationship9="" OR Relationship9=NULL THEN
            Relationship9=ORs("Rel_Fetish")
        ELSEIF Relationship9=1 THEN
            Relationship9=TRUE
        END IF
    Relationship10=Request("Relationship10")
        IF Relationship10="" OR Relationship10=NULL THEN
            Relationship10=ORs("Rel_Groupfun")
        ELSEIF Relationship10=1 THEN
            Relationship10=TRUE
        END IF
    Relationship11=Request("Relationship11")
        IF Relationship11="" OR Relationship11=NULL THEN
            Relationship11=ORs("Rel_Other")
        ELSEIF Relationship11=1 THEN
            Relationship11=TRUE
        END IF

//Age Declarations
    AgeLow=Request("AgeLow")
        IF AgeLow="" OR AgeLow=NULL THEN
            AgeLow=ORs("Agerange_Low")
        END IF
    AgeHigh=Request("AgeHigh")
        IF AgeHigh="" OR AgeHigh=NULL THEN
            AgeHigh=ORs("Agerange_High")
        END IF

        AboutYou=Request("AboutYou")
        IF AboutYou="" OR AboutYou=NULL THEN
            AboutYou=ORs("AboutYourself")
        END IF
%>
                                              <table width="95%" border="0" cellspacing="1" cellpadding="4">
                                                <% IF ErrorFound=1 THEN %>
                                                <tr valign="top">
                                                  <td width="35%" align="right" class="Font-Reg-Red" bgcolor="#F7F7F7"><b class="Font-Small-Bold-Black">We
                                                    found some Errors<br>
                                                    Please correct them and Continue:</b></td>
                                                  <td width="65%" bgcolor="#F7F7F7">
                                                    <table width="100%" border="0" cellspacing="1" cellpadding="1">
                                                      <tr>
                                                        <td width="30%" class="Font-Bold-Black" bgcolor="#EFEFEF"><i>Location:</i></td>
                                                        <td width="70%" class="Font-Bold-Black"><i>Reason:</i></td>
                                                      </tr>
                                                      <% IF AttentionErr1=1 THEN %>
                                                      <tr>
                                                        <td width="30%" bgcolor="#EFEFEF" height="18" class="Font-Small-Bold-Blue">Attention
                                                          Graber</td>
                                                        <td width="70%" height="18" class="Black-Medium"><span class="Font-Red-Error">*</span>
                                                          <span class="Font-Small-Bold-Black">Enter
                                                          something to get everyone's
                                                          Attention!</span></td>
                                                      </tr>
                                                      <% END IF %>
                                                      <% IF AttentionErr2=1 THEN %>
                                                      <tr>
                                                        <td width="30%" bgcolor="#EFEFEF" height="18" class="Font-Small-Bold-Blue">Attention
                                                          Graber </td>
                                                        <td width="70%" height="18" class="Black-Medium"><span class="Font-Red-Error">*</span><span class="Font-Small-Bold-Black">Only
                                                          Letters, Numbers &amp;
                                                          Underscore.</span></td>
                                                      </tr>
                                                      <% END IF %>
                                                      <% IF AboutYouErr3=1 THEN %>
                                                      <tr>
                                                        <td width="30%" bgcolor="#EFEFEF" height="18" class="Font-Small-Bold-Blue">About
                                                          Yourself</td>
                                                        <td width="70%" height="18" class="Black-Medium"><span class="Font-Red-Error">*</span><span class="Font-Small-Bold-Black">Must
                                                          be at least 50 Characters
                                                          in length.</span></td>
                                                      </tr>
                                                      <% END IF %>
                                                      <% IF AboutYouErr4=1 THEN %>
                                                      <tr>
                                                        <td width="30%" bgcolor="#EFEFEF" height="18" class="Font-Small-Bold-Blue">About
                                                          Yourself </td>
                                                        <td width="70%" height="18" class="Black-Medium"><span class="Font-Red-Error">*</span><span class="Font-Small-Bold-Black">Must
                                                          be under 2000 Characters
                                                          in length.</span></td>
                                                      </tr>
                                                      <% END IF %>
                                                      <% IF AboutMatchErr5=1 THEN %>
                                                      <tr>
                                                        <td width="30%" bgcolor="#EFEFEF" height="18" class="Font-Small-Bold-Blue">About
                                                          Your Match </td>
                                                        <td width="70%" class="Black-Medium"><span class="Font-Red-Error">*</span><span class="Font-Small-Bold-Black">Must
                                                          be at least 50 Characters
                                                          in length.</span></td>
                                                      </tr>
                                                      <% END IF %>
                                                      <% IF AboutMatchErr6=1 THEN %>
                                                      <tr>
                                                        <td width="30%" bgcolor="#EFEFEF" height="18" class="Font-Small-Bold-Blue">About
                                                          Your Match </td>
                                                        <td width="70%" class="Black-Medium"><span class="Font-Red-Error">*</span><span class="Font-Small-Bold-Black">Must
                                                          be under 2000 Characters
                                                          in length.</span></td>
                                                      </tr>
                                                      <% END IF %>
                                                      <% IF GenderErr7=1 THEN %>
                                                      <tr>
                                                        <td width="30%" bgcolor="#EFEFEF" height="18" class="Font-Small-Bold-Blue">Looking
                                                          for Gender</td>
                                                        <td width="70%" class="Black-Medium"><span class="Font-Red-Error">*</span><span class="Font-Small-Bold-Black">Please
                                                          select at least 1 Gender.</span></td>
                                                      </tr>
                                                      <% END IF %>
                                                      <% IF RelationshipErr8=1 THEN %>
                                                      <tr>
                                                        <td width="30%" bgcolor="#EFEFEF" height="18" class="Font-Small-Bold-Blue">Relationship
                                                          Type </td>
                                                        <td width="70%" class="Black-Medium"><span class="Font-Red-Error">*</span><span class="Font-Small-Bold-Black">Please
                                                          select at least 1 Relationship.</span></td>
                                                      </tr>
                                                      <% END IF %>
                                                      <% IF PostalErr9=1 THEN %>
                                                      <% END IF %>
                                                      <% IF DobErr10=1 THEN %>
                                                      <% END IF %>
                                                    </table>
                                                  </td>
                                                </tr>
                                                <% END IF %>
                                                <tr align="left">
                                                  <td colspan="2" bgcolor="#F7F7F7"><span class="Font-Red-Error">*</span><span class="Font-Bold-Black">Required
                                                    - You must complete these
                                                    fields to continue! </span>
                                                  </td>
                                                </tr>
                                                <tr valign="top" bgcolor="#EFEFEF" align="center">
                                                  <td colspan="2" bgcolor="#EFEFEF"><span class="Font-Red-Error">*
                                                    </span><span class="Font-Bold-Black">Profile
                                                    Attention Graber:<br>
                                                    Enter a short headline that
                                                    will grab the attention of
                                                    other members.</span><span class="Black-Medium"><br>
                                                    </span><span class="Font-Small-Bold-Black">(120
                                                    characters max.)<br>
                                                    (ie: &quot;New blonde on the
                                                    scene!&quot;) </span></td>
                                                </tr>
                                                <tr valign="top" bgcolor="#EFEFEF" align="center">
                                                  <td colspan="2" bgcolor="#EFEFEF">
                                   &
Reply With Quote
  #9 (permalink)  
Old November 30th, 2005, 04:40 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Is AboutYourself a BLOB in the database (e.g. a Text or Memo type)?

If so, put it last in your SELECT statement, Then in your code, access this column last, after all other columns have been accessed. Does that work? (There are some known issues with BLOB columns....)

Otherwise, I suggest you create a simple test bed with the required field, and then add back code until it breaks again.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #10 (permalink)  
Old November 30th, 2005, 05:04 PM
Authorized User
 
Join Date: Jun 2005
Location: HSP, , .
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Imar,

You are right. It is a text field and as soon as I put it last in my select statement, it is working now. Now the problem that I am having is that I have two text fields being selected in select statement. whichever I put last, works but the other one does not. The other field is AboutMatch and I am calling it now exactly same way I called AboutYou.

Thanks in advance,
You have been a great help.
Palvin

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

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
Display text data in textarea from SQL query palvin Classic ASP Databases 0 November 29th, 2005 05:44 PM
Cannot display/return SQL Query Output from a Vari sjm SQL Server DTS 1 September 9th, 2005 11:40 AM
display vbCrLf's from textarea to textarea mat41 Classic ASP Basics 8 June 10th, 2004 12:19 AM
Display data in textarea with select statement Alex_forever MySQL 6 April 27th, 2004 06:05 PM



All times are GMT -4. The time now is 02:09 AM.


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