A
Andreas van Bergen
Hi,
I am filling a byte[] with a string (about 1700 characters) which i want to
insert into an image field in MSSQL server. This all goes well.....accept
when i want to retrieve that particullar field, my result is a string with
16 characters...where are my other 1684 characters ??
Here is some code that i use to perform this action :
//****************************************************************************************
// This is the filling part....
//****************************************************************************************
ASCIIEncoding ascii = new ASCIIEncoding();
byte[] oByteArray = ascii.GetBytes(aStringToWrite);
StringBuilder oBuilder = new StringBuilder();
oBuilder.Append("INSERT INTO Tabel (");
oBuilder.Append("MessageContent");
oBuilder.Append(") VALUES (@MessageContent)");
SqlCommand oCommand = new SqlCommand(oBuilder.ToString());
SqlParameter pMessageContent = new SqlParameter("@MessageContent",
SqlDbType.Image, 16);
pMessageContent.Value = oByteArray;
oCommand.Parameters.Add(pMessageContent);
ExcecuteQuery(oCommand);
//****************************************************************************************
// This is the retrieving part....
//****************************************************************************************
string sSQL = String.Format("SELECT {0} FROM Tabel WHERE MessageID = {1}",
aColumnName, aMessageID);
DataTable oTable = ResultQuery(sSQL);
DataRow oRow = (DataRow)oTable.Rows[0];
byte[] oByteArray = (byte[])oRow[aColumnName];
ASCIIEncoding ascii = new ASCIIEncoding();
char[] oCharArray = ascii.GetChars(oByteArray);
string Anwser = new string(oCharArray);
//****************************************************************************************
Does anybody have a suggestion how to solve this problem?
Thanks in advance.
Andreas
I am filling a byte[] with a string (about 1700 characters) which i want to
insert into an image field in MSSQL server. This all goes well.....accept
when i want to retrieve that particullar field, my result is a string with
16 characters...where are my other 1684 characters ??
Here is some code that i use to perform this action :
//****************************************************************************************
// This is the filling part....
//****************************************************************************************
ASCIIEncoding ascii = new ASCIIEncoding();
byte[] oByteArray = ascii.GetBytes(aStringToWrite);
StringBuilder oBuilder = new StringBuilder();
oBuilder.Append("INSERT INTO Tabel (");
oBuilder.Append("MessageContent");
oBuilder.Append(") VALUES (@MessageContent)");
SqlCommand oCommand = new SqlCommand(oBuilder.ToString());
SqlParameter pMessageContent = new SqlParameter("@MessageContent",
SqlDbType.Image, 16);
pMessageContent.Value = oByteArray;
oCommand.Parameters.Add(pMessageContent);
ExcecuteQuery(oCommand);
//****************************************************************************************
// This is the retrieving part....
//****************************************************************************************
string sSQL = String.Format("SELECT {0} FROM Tabel WHERE MessageID = {1}",
aColumnName, aMessageID);
DataTable oTable = ResultQuery(sSQL);
DataRow oRow = (DataRow)oTable.Rows[0];
byte[] oByteArray = (byte[])oRow[aColumnName];
ASCIIEncoding ascii = new ASCIIEncoding();
char[] oCharArray = ascii.GetChars(oByteArray);
string Anwser = new string(oCharArray);
//****************************************************************************************
Does anybody have a suggestion how to solve this problem?
Thanks in advance.
Andreas