Help with ASP/Insert SP for Nvarchar(MAX) getting truncated

I have the following SP

SET ANSI_NULLS OFF;
GO
SET QUOTED_IDENTIFIER ON;
GO
ALTER PROCEDURE [dbo].[add_templates]
    @Firmid INT,
    @LtrName NVARCHAR(100),
    @LtrBody NVARCHAR(MAX),
    @OrderNum INT,
    @LtrType NVARCHAR(50)
AS
INSERT INTO dbo.AdminCatalogLetterMrg
(
    FirmId,
    LtrName,
    LtrBody,
    OrderNum,
    LtrType
)
VALUES
(@Firmid, @LtrName, @LtrBody, @OrderNum, @LtrType);

Open in new window


And using ASP Classic I am passing the values to the SP. But even though I am using what I think is correct code I am getting an error saying the data is being truncated.
I am not sure why because the field is nvarchar(MAX)

The example I have has 5569 characters.

Here is the ASP code. BTW I have similar code for another insert and that one works fine.

Dim sp_addtemplate__Firmid
sp_addtemplate__Firmid = "0"
if(session("Firmid") <> "") then sp_addtemplate__Firmid = session("Firmid")

Dim sp_addtemplate__LtrName
sp_addtemplate__LtrName = "0"
if(Request("LtrName") <> "") then sp_addtemplate__LtrName = Request("LtrName")

Dim sp_addtemplate__LtrBody
sp_addtemplate__LtrBody = "0"
if(Request.Form("summernote") <> "") then sp_addtemplate__LtrBody = Request.Form("summernote")

Dim sp_addtemplate__OrderNum
sp_addtemplate__OrderNum = "0"
if("0" <> "") then sp_addtemplate__OrderNum = "0"

Dim sp_addtemplate__LtrType
sp_addtemplate__LtrType = "0"
if(Request("ltrtype") <> "") then sp_addtemplate__LtrType = Request("ltrtype")

%>

<%

set sp_addtemplate = Server.CreateObject("ADODB.Command")
sp_addtemplate.ActiveConnection = MM_bluedot_STRING
sp_addtemplate.CommandText = "dbo.add_templates"
sp_addtemplate.CommandType = 4
sp_addtemplate.CommandTimeout = 0
sp_addtemplate.Prepared = true
sp_addtemplate.Parameters.Append sp_addtemplate.CreateParameter("@RETURN_VALUE", 3, 4)
sp_addtemplate.Parameters.Append sp_addtemplate.CreateParameter("@Firmid", 3, 1,4,sp_addtemplate__Firmid)
sp_addtemplate.Parameters.Append sp_addtemplate.CreateParameter("@LtrName", 200, 1,100,sp_addtemplate__LtrName)
sp_addtemplate.Parameters.Append sp_addtemplate.CreateParameter("@LtrBody", 202, 1, Len( "" & sp_addtemplate__LtrBody ), sp_addtemplate__LtrBody)
sp_addtemplate.Parameters.Append sp_addtemplate.CreateParameter("@OrderNum", 3, 1,4,sp_addtemplate__OrderNum)
sp_addtemplate.Parameters.Append sp_addtemplate.CreateParameter("@LtrType", 200, 1,50,sp_addtemplate__LtrType)
sp_addtemplate.Execute()

Open in new window


This is the error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e21'

[Microsoft][ODBC SQL Server Driver]String data, right truncation

/bluedot_qtr4_2017/admin/sp_addtemplate.asp, line 50
LVL 1
AleksAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ares KurkluSoftware EngineerCommented:
is 202 the right type for LtrBody  ?
0
Ares KurkluSoftware EngineerCommented:
I think it may need to be 203 have a look at the adLongVarWChar
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AleksAuthor Commented:
I have 202 for another stored procedure got nvarchar max  and it works fine.
0
AleksAuthor Commented:
I changed it to 203 and it worked ... so I guess you are correct. Thanks for the help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.