Solved

Fetching data from TEXT-field through ASP

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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

705 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

13 Experts available now in Live!

Get 1:1 Help Now