Search code examples
sql-server-2008iis-7asp-classicvbscript

Strange problem with nvarchar(max) fields and Classic ASP


I'm working on a Classic ASP (VBScript) site that's running on a Windows 2008 server with IIS7 and hitting a SQL Server 2008 database and I'm seeing some strange behavior that seems to be specific to fields that are of type nvarchar(max).

I have this simple bit of code that loops over some query results and tries to print out the title field twice

rs.open "SELECT * FROM thing", dbConnection

do while not rs.eof
    response.write "(" & rs("title") & ")" & "(" & rs("title") & ")" & "<br />"
    rs.movenext
loop

The first time I use rs("title"), I get the value back. Any time after the first time in that loop, rs("title") returns a blank value.

Again, this only seems to happen with the nvarchar(max) fields.

Can anyone shed any light on this behavior and how to get around it?


Solution

  • If you take a look at this link, http://msdn2.microsoft.com/en-us/library/ms130978.aspx it says to enable SQL Server Native Client to get the latest features such as varchar(max) which was was introduced in SQL2005, so I think maybe using this would work for you as well even though you're using SQL 2008.