Solved

Fetching data from TEXT-field through ASP

Posted on 1998-07-08
3
252 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

733 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