Resordset cannot write TEXT & CHAR data type problem

Discussion in 'ASP General' started by Ang, Feb 20, 2008.

  1. Ang

    Ang Guest

    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
    %>


    *** Sent via Developersdex http://www.developersdex.com ***
    Ang, Feb 20, 2008
    #1
    1. Advertising

  2. Ang wrote:
    > 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


    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Feb 20, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. luna
    Replies:
    1
    Views:
    6,804
  2. wwj
    Replies:
    7
    Views:
    542
  3. wwj
    Replies:
    24
    Views:
    2,484
    Mike Wahler
    Nov 7, 2003
  4. lovecreatesbeauty
    Replies:
    1
    Views:
    1,015
    Ian Collins
    May 9, 2006
  5. Replies:
    3
    Views:
    721
Loading...

Share This Page