Solved

Fetching data from TEXT-field through ASP

Posted on 1998-07-08
3
264 Views
Last Modified: 2010-03-19
In asp, how can I read a field with the datatype TEXT?
0
Comment
Question by:ribbegrd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 1091682
Supposing you have a connection named Conn:

<%
Set RS = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT field_name FROM table WHERE.... ORDER BY...."
RS.Open strSQL, Conn, 1, 1

field_contents = RS("field_name")

%>

It is important that you create the recordset this way and not (as works in Access) with:

<%
strSQL = "SELECT..etc"
Set RS = Conn.Execute(strSQL)
%>
In SQL this gives problems with text fields


0
 

Author Comment

by:ribbegrd
ID: 1091683
<%
set Conn=server.createobject("adodb.connection")
Set RS = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM people WHERE pwd = " & "'" & Request.ServerVariables("LOGON_USER")& "'"
RS.Open strSQL, Conn, 1, 1
field_contents = RS("fnamn")
response.write field_contents
RS.Close
%>

This results in the following error:
"ADODB.Recordset error '800a0e7d'

The application requested an operation on an object with a reference to a closed or invalid Connection object.

/showroom/admin/insert2.asp, line 23"

Line 23 is "RSE.Open strSQL, Conn, 1, 1"

Any ideas?
0
 
LVL 28

Accepted Solution

by:
sybe earned 100 total points
ID: 1091684
You don't have a connection, you only create the Conn object, but you should call the ODBC connection to the database:

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=ODBC_Name;SERVER:SQL-Server_Name;UID=sa;PWD=;APP=;DATABASE=Database_Name"

etc etc.

Of course you should make an ODBC connection to the database


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question