Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Updating SQL Server Text field problem
Message
 
À
15/01/2004 10:26:31
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Divers
Thread ID:
00867111
Message ID:
00867122
Vues:
19
Hi Steve,

Yes, it is declared as Text.

>Allan,
>
>Are you sure that the parameter for the text field in your stored proc is declared as Text?
>
>
>
>
>>Hi,
>>
>>I am using a third party control to provide Rich Text functionality in my app (TX Text Control). When saving the contents of the control to a string, all of the RTF encoding appears in the string - as is to be expected. I want to save this string to a text field in a SQL Server database.
>>
>>The problem is that only the first handful of characters in the string are being saved to the database (see below).
>>
>>Here is the code in my C# data access layer that peforms that update function (note, this function calls a stored procedure that performs the update- passing the Template Id and template text):
>>
>>
>>
>>public int fnUpdate(int pTemplatesID, string pTemplateTextTX)
>>{
>>//Create the command object
>>SqlCommand cmdUpdate = new SqlCommand("UP_Update_Templates",this.objConn());
>>
>>//The command type is a Stored Procedure
>>cmdUpdate.CommandType = CommandType.StoredProcedure;
>>
>>// Parameter for field 'TemplatesID'
>>SqlParameter parmTemplatesID = cmdUpdate.Parameters.Add("@TemplatesID",SqlDbType.Int,4);
>>parmTemplatesID.Value = pTemplatesID;
>>
>>// Parameter for field 'TemplateTextTX'
>>SqlParameter parmTemplateTextTX = cmdUpdate.Parameters.Add("@TemplateTextTX",SqlDbType.Text,16);
>>parmTemplateTextTX.Value = pTemplateTextTX;
>>
>>// Parameter to hold Return Value
>>SqlParameter parmReturnValue = cmdUpdate.Parameters.Add("@ReturnValue",SqlDbType.Int,4);
>>parmReturnValue.Direction = ParameterDirection.Output;
>>
>>Console.WriteLine(pTemplateTextTX);  // ** FOR TESTING PURPOSES **
>>
>>//Execute the Update Stored Procedure and
>>//write exceptions to the console for testing purposes
>>
>>try
>>{
>>cmdUpdate.ExecuteNonQuery();
>>}
>>catch (System.Exception e)
>>{
>>Console.WriteLine(e.ToString());  // ** FOR TESTING PURPOSES **
>>
>>}
>>
>>//Save the value returned from the Stored Procedure to a memvar
>>int RetVal = Convert.ToInt32(cmdUpdate.Parameters["@ReturnValue"].Value.ToString());
>>
>>//Return the integer returned from the Stored Procedure
>>return RetVal ;
>>
>>}
>>
>>
>>
>>Note that the value of parameter 'parmTemplateTextTX' contains text that looks like this:
>>
>>
>>
>>{\rtf1\ansi\ansicpg1252\uc0\deff1{\fonttbl
>>{\f0\fswiss\fcharset0\fprq2 Arial;}
>>{\f1\fmodern\fcharset0\fprq1 LinePrinter;}
>>{\f2\froman\fcharset0\fprq2 Times (PCL6);}
>>{\f3\fswiss\fcharset0\fprq2 Helv;}
>>{\f4\froman\fcharset0\fprq2 Times New Roman;}
>>{\f5\froman\fcharset2\fprq2 Symbol;}}
>>... and much more
>>
>>
>>
>>However, the only text that is being updated into the field that contains the template text is:
>>
>>
>>
>>{\rtf1\ansi\ansi
>>
>>
>>
>>In the C# code above, the line 'Console.WriteLine(pTemplateTextTX);' copies the contents of the string to the console - if I copy the entire text string and paste it into Query Analyzer to run the update statement - the field is updated with the entire string. However, when running my app, only the first few characters (see above) are being updated.
>>
>>Any idea what may be causing this?
Al Williams

Anola MB, CANADA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform