troubleshooting Question

output from Sql Server is being truncated

Avatar of Mark Klein
Mark KleinFlag for United States of America asked on
ASP.NETMicrosoft SQL Server 2005
5 Comments1 Solution329 ViewsLast Modified:
I have a stored proc that queries a table. One field is nvarchar, of length 400.  The proc is below. Despite my declarations the field is always truncated to 50 characters, which I suspect is a default value.  where is this happening.  How can I stop it?
ALTER PROCEDURE dbo.uspGetMailFields @msgName NVARCHAR (50), @msgbody nvarchar (400) OUTPUT, @msgSubject nvarchar (50) OUTPUT, @Recipient nvarchar (50) OUTPUT
AS
BEGIN
       SELECT    @msgSubject=msgSubject, @msgbody=msgBody, @Recipient=recipient
       FROM eMailMessages
       WHERE msgName = @msgName
END

GO

The parameters in the code-behind are
cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@msgName", SqlDbType.NVarChar, 50)).Value = msgName
        cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@msgSubject", SqlDbType.NVarChar, 400))
        cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@msgbody", SqlDbType.NVarChar, 50))
        cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@recipient", SqlDbType.NVarChar, 50))

        cmd.Parameters("@msgSubject").Direction = ParameterDirection.Output
        cmd.Parameters("@msgBody").Direction = ParameterDirection.Output
        cmd.Parameters("@recipient").Direction = ParameterDirection.Output

        'Execute the Stored Procedure to collect the email message body,subject line, and recipient type 
        con.Open()
        cmd.ExecuteNonQuery()

        Dim subject As String = CType(cmd.Parameters("@msgSubject").Value, String)
        Dim body As String = CType(cmd.Parameters("@msgBody").Value, String)
        Dim recipientType As String = CType(cmd.Parameters("@recipient").Value, String)

Is it the Dim body line?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros