I am migrating a Classic ASP application to a newer SQL Server database server.
The new server is a Windows 2019 Server (version 10.0.17763). I have an ADODB connection (version 10.0) to the SQL Server 2019 database (database is migrated from an older version).
It seems that the application runs almost perfectly, but among the dozens of ADODB queries that work fine is one that returns corrupted data.
UPDATED: It turns out that the only columns affected are indeed nvarchar(max) columns. As such, this is a duplicate of this question. My original question's detail follows:
If I run the stored procedure in SQL Management Studio, the results are perfect:
SELECT dbo.[Staff.Reports].[Report Title], replace(dbo.[Staff.Reports].[Description],char(34),'') as RepDesc
FROM dbo.[Staff.Reports] LEFT OUTER JOIN dbo.[Staff.Reports Permissions] ON dbo.[Staff.Reports].[Report ID] = dbo.[Staff.Reports Permissions].[Report ID]
WHERE dbo.[Staff.Reports Permissions].[Staff ID] = @StaffID
Returns:
Report Title | RepDesc |
---|---|
Achievements Admin | Update OAA, and other Achievements |
AdRef By Engineers | AdRef By Engineers |
Adref Status Count | Ad Campaign report by ref no. |
etc.
However, when the identical query is run through the Classic ASP code, using the ADODB connection, the data returned becomes corrupted:
Report Title | RepDesc |
---|---|
Achievements Admin | ] 0 |
AdRef By Engineers | |
Adref Status Count | 0 |
Out of interest, the description column is an nvarchar(max)
type. I established the content of the output by logging it to a text output file - it's not an issue with the display of the data.
The output is the same number of characters, but they are mostly null and control characters.
I have tried deleting and recreating the query, but am at a loss as to what is happening.
Can anyone help, please?
Thanks for your interest, AlwaysLearning. All queries are run using the same 'GetRecordset' function, which is basically:
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Open "Data Source=TheDatabase;UID=Fred;Password=" & strPassword
oConnection.CursorLocation = 3
Set CreateConnection = oConnection
Set objComm = Server.CreateObject("ADODB.Command")
objComm.ActiveConnection = CreateConnection
objComm.CommandType = adCmdStoredProc
objComm.CommandText = cQuery
objComm.CommandTimeout = 1800
For iThisParameter = 1 to UBound(aParameters)
Set objParam = objComm.CreateParameter("@par" & iThisParameter, adVarChar, adParamInput, 1024)
objComm.Parameters.Append objParam
objComm.Parameters("@par" & iThisParameter) = aParameters(iThisParameter)
Next
Set GetRecordset = objComm.Execute