1
Reply

how to retrive images from database

nregasunam sunam

nregasunam sunam

Jun 16 2015 2:44 AM
333
i want to search image from database.
my code is below

try

{

int n = Convert.ToInt32(Interaction.InputBox("Enter sno:", "Search", "20", 100, 100));

DataRow drow;

drow = ds.Tables[0].Rows.Find(n);

if (drow != null)

{

rno = ds.Tables[0].Rows.IndexOf(drow);

textBox1.Text = drow[0].ToString();

textBox2.Text = drow[1].ToString();

textBox3.Text = drow[2].ToString();

pictureBox1.Image = null;

if (drow[3] != System.DBNull.Value)

{

photo_aray = (byte[])drow[3];

MemoryStream ms = new MemoryStream(photo_aray);

pictureBox1.Image = Image.FromStream(ms);

}

}

else

MessageBox.Show("Record Not Found");

}

catch(Exception ex)

{

MessageBox.Show(ex.Message.ToString());

}

 
Error is
Parameter is not valid 
 
 

Answers (1)