Hi, everyone this is my issue I have to read a binary record from the database and concatenate another string to it, the thing is that is just working one way, I ll put some code to explain better.

buffer = rdGetBinary.GetInt32(3);//this is the length of the actual row from the database.
                            byte[] outbyted = new byte[buffer];
                            startindex = 0;
                            retvale = rdGetBinary.GetBytes(2, startindex, outbyted, 0, buffer);
                            string bina = System.Text.Encoding.ASCII.GetString(outbyted);
                            string Combined = "";
                            Combined = bina.Replace("Q.A","Q.C")+ "\n\n" + PreBina; //which PreBina is another string variable, now this is working but if i do this Combined = PreBina + "\n\n" + bina.Replace("Q.A","Q.C") will not work.
                            SqlCommand UpdateBinary = new SqlCommand();
                            long buffert = (long)Combined.Length;
                            byte[] photo = new byte[buffert];
                            photo = System.Text.Encoding.UTF8.GetBytes(Combined);
                            UpdateBinary.CommandText = "UPDATE OPERATION_BINARY SET BITS = @Photo, BITS_LENGTH = '" + photo.Length + "' WHERE WORKORDER_BASE_ID = '" + dsGetOperation.Tables[0].Rows[i][0].ToString() + "' AND WORKORDER_LOT_ID = '" + dsGetOperation.Tables[0].Rows[i][1].ToString() + "' AND WORKORDER_TYPE = 'M' AND SEQUENCE_NO = '" + PreSeq + "'";
                            UpdateBinary.Connection = conne;
                            UpdateBinary.Parameters.Add("@Photo", SqlDbType.Image, photo.Length).Value = photo;

I really do not understand this behavior, I just post it just in case somebody occasionally have had this issue before.

Thanks all.

9 Years
Discussion Span
Last Post by jbisono

Hi friends, I fixed the problem PreBina Variable was holding a hide delimiter character at the end of the string and that was stopping the correct function or result that i wanted. anyway I just did this.

PreBina.Remove(PreBina.Length -1,1)

now is happy. thanks anyway.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.