G
Guest
I want to inser a Text string as a BLOB
When I try to insert a series of records I get the following problem
-- System.Data.SqlClient.SqlException: String or binary data would be truncated
My table has three nvarchar 50 columns, (MessageId, PutDate, MsgType
and a Text column (RawMessage), which I want to use as large storage container for XML messages
So I read the XML Messages and want to insert each into the Database
The code of the INSERT Part looks like this
private static void InsertIntoDB(byte[] msgId, DateTime putDate, string message
tr
string commandText = "INSERT INTO message (MessageId, PutDate, MsgType, RawMessage) "
"VALUES ('"+BitConverter.ToString( msgId )+"','"+putDate.ToString("u")+"','Type',@RawMessage)"
command.Connection = con
command.CommandText = commandText
command.Parameters.Clear()
SqlParameter msg = new SqlParameter("@RawMessage",SqlDbType.Text,message.Length)
msg.Value = message
command.Parameters.Add( msg )
command.ExecuteNonQuery()
catch(Exception e
Console.WriteLine(e.ToString())
Console.WriteLine("Neither record is written to the database!")
Any Help?
When I try to insert a series of records I get the following problem
-- System.Data.SqlClient.SqlException: String or binary data would be truncated
My table has three nvarchar 50 columns, (MessageId, PutDate, MsgType
and a Text column (RawMessage), which I want to use as large storage container for XML messages
So I read the XML Messages and want to insert each into the Database
The code of the INSERT Part looks like this
private static void InsertIntoDB(byte[] msgId, DateTime putDate, string message
tr
string commandText = "INSERT INTO message (MessageId, PutDate, MsgType, RawMessage) "
"VALUES ('"+BitConverter.ToString( msgId )+"','"+putDate.ToString("u")+"','Type',@RawMessage)"
command.Connection = con
command.CommandText = commandText
command.Parameters.Clear()
SqlParameter msg = new SqlParameter("@RawMessage",SqlDbType.Text,message.Length)
msg.Value = message
command.Parameters.Add( msg )
command.ExecuteNonQuery()
catch(Exception e
Console.WriteLine(e.ToString())
Console.WriteLine("Neither record is written to the database!")
Any Help?