Connecting Tech Pros Worldwide Forums | Help | Site Map

How to display data from a bytearray to a textbox

Newbie
 
Join Date: Mar 2007
Posts: 13
#1: Apr 2 '07
anybody can help me to display the bytearray data into a text box????
i am able to use the Response.BinaryWrite()....

SqlConnection con=new SqlConnection("server=localhost;Persist Security Info=False;User ID=sa;password=sa;Initial Catalog=;Data Source=server0");

SqlCommand cmd = new SqlCommand("select book from name where id='" + TextBox3.Text + "'", con);
con.Open();

SqlDataReader dr = cmd.ExecuteReader();
//Allocate an array of bytes to store it in temporarily:
byte[] image = null;
while (dr.Read())
{
image = (byte[])dr.GetValue(0);

string output = System.Text.Encoding.Unicode.GetString(image);
//TextBox4.Text=output;
Response.BinaryWrite(image);

SammyB's Avatar
Moderator
 
Join Date: Mar 2007
Location: Springfield, Ohio
Posts: 729
#2: Apr 2 '07

re: How to display data from a bytearray to a textbox


Quote:

Originally Posted by sumithsumith

anybody can help me to display the bytearray data into a text box????
i am able to use the Response.BinaryWrite()....

SqlConnection con=new SqlConnection("server=localhost;Persist Security Info=False;User ID=sa;password=sa;Initial Catalog=;Data Source=server0");

SqlCommand cmd = new SqlCommand("select book from name where id='" + TextBox3.Text + "'", con);
con.Open();

SqlDataReader dr = cmd.ExecuteReader();
//Allocate an array of bytes to store it in temporarily:
byte[] image = null;
while (dr.Read())
{
image = (byte[])dr.GetValue(0);

string output = System.Text.Encoding.Unicode.GetString(image);
//TextBox4.Text=output;
Response.BinaryWrite(image);

It would depend on how the characters are packed into your byte array, but don't you want something like this:
Expand|Select|Wrap|Line Numbers
  1.  byte[] b = new byte[] { 65, 66, 67 };
  2. MessageBox.Show( System.Text.Encoding.ASCII.GetString(b));
Reply