Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello,
I want to get documents from sqlserver without lossing original format into multiline text box .I had tried below code but i lossed my original format can u guide me or send snippets. can u tell where i done mistake
database:sqlserver 2008
document column name: fcontent varbinary(max)




string connectionString = ConfigurationManager.ConnectionStrings["uploadConnectionString"].ConnectionString;
connection = new SqlConnection(connectionString);
connection.Open();

SqlCommand cmd = new SqlCommand("select fcontent from files where id=@id", connection);
cmd.Parameters.Add("@id", SqlDbType.Int).Value = 2;


byte[] resume = (byte[])cmd.ExecuteScalar();

String text = System.Text.Encoding.UTF8.GetString(resume);


TextBox1.Text = text;
connection.Close();
}


Name : V.KRISHNAVENI
Father�s Name : V.CHINNA VENKAIAH
Date of Birth : 22-05-1990
Sex : Female
Marital status : Single
Nationality : Indian
Languages Known : English, Telugu
Permanent Address : V.KRISHNAVENI,
D/O V.Chinna Venkaiah,
Peddagopathi(V),
Konijerla(M),
KHAMMAM(D).

I do here by declare that the above details are true to the best of my knowledge and belief.
Date:
Place:
KRISHNAVENI VADDE
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������)��5��>��?��a��f��g��h��z�����; ��L ��M ��z ��| ��� ��� ��� ��� ��� ��� ��� ��� ����������׾�ם�~�n`R`RDR`R`��h[SW�B*"OJ��QJ��^J��ph����h�`��B*"OJ��QJ��^J��ph����h�iA�B*"OJ��QJ��^J��ph����h�iA�5�B*"OJ��QJ��^J��ph�����)h�iA�5�B*"CJ�OJ�QJ�\�^J�aJ�ph����h�iA�OJ��QJ��^J���h�iA�OJ'�QJ'�^J'��,h�iA�5�CJ�OJ�QJ�\�^J�aJ�mH�nH�sH��j����h�iA�U" h�`��5�CJ�OJ�QJ�\�^J�aJ�� h�iA�5�CJ�OJ�QJ�\�^J�aJ��h�iA�5�CJ�\�aJ��h�iA�5�>*CJ �\�aJ ���������*��?��f��h��z��|��; ��L ��M ��N ��U ��V ��W ��g ��h ��m ��n ��z �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
��$"$"G$�If"���a$"� ��$��'dh""�`��'a$�"���"�$"
& F��
� �����dh""����$"a$"�z ��{ ��| ��� ��� ��� ��� ��Y������������N������������N������������N������������@������������N�����������������������������������
��$"$"G$�If"���a$"gd[SW��
��$"$"G$�If"���a$"����kd����$"$"If"����H'�\�����}�!�v""�""�""�������
""�""�""�������""�""�""������ ""�""�""�""� ��'�'�'�'�(�����������������������������������������"����������������������������������������������������������������������������4��"��4��"
l�a���p�(������������������������������������������ ��� ��� ��� ��� ��� ��� ��� ������������������������������������������������������@�����������������������������������������������kd "��$"$"If"����%'�\�����}�!�v""�""�""�������
""�""�""�������""�""�""������ ""�""�""�""� ��"�"�"�"�(�����������������������������������������"����������������������������������������������������������������������������4��"��4��"
l�a���p�(�����������������������������������������
��$"$"G$�If"���a$"�
��$"$"G$�If"���a$"gd�`���� ��� ��� ��� ��� ��� ��� ��� ��
��
��
��
��
��
��
��
��7
��8
��P
��Q
��W
��b
��n
��~
���
���
���
���
���
���
���
�����������������ʷ���㦇㦇�yd����������������������������������������������)h���5�B*"CJ�OJ�QJ�\�^J�aJ�ph����h�}�B*"OJ��QJ��^J��ph����hgm��B*"OJ��QJ��^J��ph����!
Posted
Updated 16-Feb-12 19:56pm
v2

1 solution

You are saving data in binary format and may be these files are .doc,.pdf,.rtf etc
one possible solution is to store on address of these files and store file physically some where else in directory i.e c:\dir\a.pdf
and secondly you can reconstruct them run time as you are doing, but you are actually converting binary data to text that's why you are seeing such output.
Either case we can't do this, we can't display binary data in text box. If you have to show this information in text boxes then you have to convert incoming data to plane text or html.other wise user have to download file on their local system to view file.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900