SQL Server 2022 don't display data from varchar(max) in Classic ASP

Ricard Sentís 0 Reputation points
2023-10-30T15:11:43.9+00:00

In a recently update to SQL Server 2022, the data from the varchar(max) fields has stopped being displayed (or being saved in variables) on a website made with ASP Classic.

How can I solve this problem?

Here is the code:

<%

	set db = server.CreateObject("ADODB.Connection")
	set rs = server.CreateObject("ADODB.Recordset")
	db.Open(connectionstring)

	'Page is varchar(10) and Content is varchar(MAX)
	sql = "SELECT Page, Content FROM Aux_Config" 
	rs.open sql,db,1
	while not rs.EOF 
		response.write("<br/>Element: " & rs.fields("Page"))
		If rs.fields("Content")="" Then
			response.write("<br/>Content: (empty)")
		Else
			response.write("<br/>Content: " & rs.fields("Content"))
		End If
		rs.movenext
	wend
	rs.close

%>

I have tried with different connection strings:

connectionstring="Driver={SQL Server};Server=server;Database=database;Uid=user;Pwd=password;"
connectionstring="Driver={ODBC Driver 11 for SQL Server};Server=server;Database=database;Uid=user;Pwd=password;"
connectionstring="Driver={ODBC Driver 17 for SQL Server};Server=server;Database=database;Uid=user;Pwd=password;"
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,450 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,638 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 63,746 Reputation points
    2023-11-03T20:37:51.68+00:00

    your syntax is wrong, you are displaying the field properties, not row values. try:

        while not rs.EOF 
    		response.write("<br/>Element: " & rs("Page"))
    		If rs("Content")="" Then
    			response.write("<br/>Content: (empty)")
    		Else
    			response.write("<br/>Content: " & rs("Content"))
    		End If
    		rs.movenext
    	wend
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.