• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 71
  • Last Modified:

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
0
Aleks
Asked:
Aleks
  • 2
  • 2
1 Solution
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now