Solved

Fetching data from TEXT-field through ASP

Posted on 1998-07-08
3
217 Views
Last Modified: 2010-03-19
In asp, how can I read a field with the datatype TEXT?
0
Comment
Question by:ribbegrd
  • 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now