Resordset cannot write TEXT & CHAR data type problem

A

Ang

Dear all,
I'm a newbie of ASP, and I found that my code cannot output the data
when the DATA type set to TEXT or CHAR, it can only show int & varchar
in MSSQL, what can I do to show TEXT & CHAR data on my page? Many
thanks.

My code is here.

<%
' Use vid to fetch information from server for the video
Sub showMovie(VID)
Dim width, height ' width and height of video
Dim ConnString, SQL, Connection, Recordset

width = "300"
height = "200"
ConnString = "DRIVER={SQL
Server};SERVER=serverName;UID=login;PWD=password;DATABASE=video"
SQL = "SELECT * FROM table_video WHERE vid = " & VID

' Create an instance of the ADO connection and recordset objects
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")

Connection.Open ConnString ' Open the connection to the database
Recordset.Open SQL,Connection ' Open the recordset object executing the
SQL statement and return records

' First of all determine whether there are any records
If Recordset.EOF Then
Response.Write("No records returned.")
Else
'show record information
' "description" is TEXT data type, "grade" is CHAR data type
%>
<h1><%=Recordset("title")%></h1>
<p>Category: <%=Recordset("category")%></p>
<p>Time: <%=Recordset("dateadd")%></p>
<p>User: <%=Recordset("uid")%>, Grade: <%=Recordset("grade")%></p>
<embed src="<%=Recordset("filename")%>" width=<%=width%>
height=<%=height%> />
<p>Description:<br /><%=Recordset("description")%></p>
<%
End If

'close the connection and recordset objects to free up resources
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing
End Sub

' vid (video id) numeric checking and validation (if empty)
If Len(Request.Querystring("vid")) > 0 AND
IsNumeric(Request.Querystring("vid")) Then
call showMovie(Request.Querystring("vid"))
Else
Response.write ("Invalid Video ID.") ' error message
End If
%>
 
B

Bob Barrows [MVP]

Ang said:
Dear all,
I'm a newbie of ASP, and I found that my code cannot output the data
when the DATA type set to TEXT or CHAR, it can only show int & varchar
in MSSQL, what can I do to show TEXT & CHAR data on my page? Many
thanks.

My first thought was that you were running into a very old bug caused by
using the obsolete ODBC driver instead of the native SQL Server OLE DB
provider. Sure enough ...
ConnString = "DRIVER={SQL Server}
See http://www.aspfaq.com/show.asp?id=2126
SQL = "SELECT * FROM table_video WHERE vid = " & VID

See these two articles:

http://www.aspfaq.com/show.asp?id=2096
http://databases.aspfaq.com/databas...memo-text-hyperlink-and-currency-columns.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top