Kathleen Dollard
1/22/2003 6:01:00 PM
Brendan,
How is the field defined in SQL Server?
Kathleen
"Brendan Nolan" <brendan.nolan@aztech.ie> wrote in message
news:O$l6LKVwCHA.2372@TK2MSFTNGP09...
> Hi,
>
> Thanks in advance for any help with this.
>
> I have a function calling the code below. The code runs fine and returns
no
> errors or exceptions but it doesn't always properly insert the value
> @Message into the database. The problem seems to be with the length of the
> string. I have a string that has a length of 420 and that is inserted fine
> but a string with a length of 8076 gets inserted as "".
>
> I've debugged down thru the code and the string value is stored correctly
in
> the Parameters collection but never makes if to SQL.
>
> @Message is defined as a text parameter in stored procedure and database
it
> inserts into.
>
> I'm using this as my connection string
>
> Password=bbbbbbbb;User ID=sa;Initial Catalog=iBrokerExchange;Data
> Source=SQLSERVER
>
> Thanks
>
> Brendan
> SqlConnection myConnection = null;
> string messageString = null;
> try
> {
> myConnection = new SqlConnection(connectionString);
> myConnection.Open();
> SqlCommand myCommand = new SqlCommand();
> myCommand.Connection = myConnection;
> myCommand.CommandType = CommandType.StoredProcedure;
> myCommand.CommandText = "LogMessage";
> SqlCommandBuilder.DeriveParameters(myCommand);
> myCommand.Prepare();
> TextReader reader = new StreamReader(newStream);
> messageString = reader.ReadToEnd();
> myCommand.Parameters["@OwnerId"].Value = 5;
> myCommand.Parameters["@OwnerType"].Value = messageString.Length;
> myCommand.Parameters["@Direction"].Value = direction;
> myCommand.Parameters["@Message"].Value = messageString;
> myCommand.ExecuteNonQuery();
> }
> finally
> {
> myConnection.Close();
> }
>
>