Paul Hughes

Paul Hughes

  • NA
  • 1
  • 0

SqlParameter limit of 127 characters

Mar 15 2007 8:00 AM

I am developing a watcher service that picks up an xml file from a directory .
using System.XML  I  read through the XML to provide a string

XMLStr = XMLStr+"'"+(pda.ReadInnerXml())+"'";

I then pass this string to my SQL Command to provide the Parameter to a stored procedure

cmdnew.Parameters.Add(XMLStr, SqlDbType.NText,);
(the stored procedure uses openxml to load the database)
when I run the application I get the error
The length of the parameter '' all the xml code------''
exceeds the limit of 127 characters

I have tried to split the xml file into 128 character chunks but this will be dificult as the xml file lenth will be variable.

I have  also tried various SqlDbTypes all with the same result.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataSqlDbTypeClassTopic.asp

Just to check things out I pased the XML as a parameter for the Stored procedure in a query Window and it works  so that points to the c# code being the problem

anyone any Ideas??

Most appreciated
Paul