Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text datatype (SQL database)

Status
Not open for further replies.

lucasm

IS-IT--Management
Feb 13, 2002
114
0
0
US
I've made a form to access a field in an SQL database, the field is "text" datatype, when I try to display it in a text box or textarea nothing shows up. I've made a local database that is the same as the master one except the datatype is "varchar" and everyone works fine. Do I have to change my SQL statement to get this field? I can't edit the master database at all, so the field has to stay in the text format.
 
Hi

Add quotes to the value attribute of the textarea element.

<input textarea value = &quot;&quot; & strFromDb & &quot;&quot;>&quot;

hth
Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
you mean like this:
<TEXTAREA name = &quot;memotext&quot; Rows = &quot;8&quot; Cols = &quot;68&quot; value=&quot;&quot; & <%=objRS(&quot;prmemo&quot;)%> & &quot;&quot;></TEXTAREA>

?
it didn't work.
 
I've had the same problem today. What I found out is that you have to execute an entire separate SQL statement to get it to work.

I did this:
<textarea name=&quot;txtmtext&quot; id=&quot;txtmtext&quot; rows=&quot;28&quot;>
<%
mydsn=&quot;dsn=chconn&quot;
mysql=&quot;select minuteid, mtext from tblminutes where minuteid = &quot; & mminuteid & &quot; &quot;
set conn=server.createobject(&quot;adodb.connection&quot;)
conn.open mydsn
set rstemp=conn.execute(mysql)
response.write(rstemp(1))
%>
</textarea>

Explanation:
minuteid = The main id of the SQL Server table
mtext = The text data type field in the SQL Server table
rstemp(1) = Is the text field I was trying to display within the textarea. It's the second column of the SQL statement result (the first column is 0 (zero) or minuteid.

I hope this helps. Someone clued me in on using SQL statements because they didn't use recordset methods. Thanks Steve!

Good luck! Chris
 
Oh, and I forgot one thing:

mminuteid is simply a variable set to the text field in your database. You set that earlier before executing the statement, of course.

Chris
 
Not the text field, but the ID field, I mean.

I'll get it right eventually.
 
You should not have to run another SQL query to ge the data. It is a format problem with the way that the RS field is placed into the textarea. I have never had to run another query to do this type of action.

hth Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
here's what I've been trying to do, prMemo is the field which is text data type.


<%
strQuery = &quot;SELECT prMemo, prName FROM PR WHERE prProject = '&quot; & Request(&quot;prProject&quot;) & &quot;'&quot;
set objRS = CreateObject(&quot;ADODB.Recordset&quot;)
objRS.Open strQuery, strConnection
%>

<TEXTAREA name = &quot;memotext&quot; Rows = &quot;8&quot; Cols = &quot;68&quot;><%=objRS(&quot;prMemo&quot;)%></TEXTAREA>
 
Two things, assuming that the problem is the query and perhaps it might be why you're not getting any result.

1. Is Request(&quot;prProject&quot;) an integer, numeric or any other type of number? If so, I thought that single quotes weren't necessary.

2. Should Request(&quot;prProject&quot;) be set to a variable first?

3. Does prProject have to be part of what's selected along with prMemo and PrName?

Try this if the above conditions are met:
SELECT prMemo, prName, prProject FROM PR WHERE prProject = &quot; & vProject & &quot; &quot;

Where vProject is the variable set to Request(&quot;prProject&quot;).

Chris
 
asp1:

...
<a href=&quot;javascript:void(0);&quot; onClick=&quot;javascript:window.open('
this is where my second page gets prProject, which is an integer in the database.
What I want to know is why this all works fine when the datatype for prMemo in the database is 'varchar' but when it is 'text' I get a blank textarea.
 
I heard of a quirk that may be causing the problem. Someone mentioned putting the field in your table as the last field. For some reason, he said that ASP won't read a text data type field unless it's the last field in the table.
Chris
 
Look up GetChunk in ADO help file.
codestorm
Fire bad. Tree pretty. - Buffy
Hey, I'm operating on a limited mental budget here.
<insert witticism here>
 
jicirtano, it was something similar to that:
I had to put the text field last in my select statement - I used to have it &quot;SELECT prMemo, prName FROM.....&quot; and it worked once I change it to &quot;SELECT prName, prMemo FROM.....&quot;

thanks
 
Cool, glad you figured it out.
Chris
Aka: cjircita
Aka: jircitano
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top