TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sakthis
NA
50
18.7k
Problem retrieve image from sql table in c#?
Oct 14 2013 5:46 PM
Hi,
I have problem while retrieve image from sql table to picturebox in c#, can anyone?
This is my code :
private void btnSearch_Click(object sender, EventArgs e)
{
SqlConnection CN = new SqlConnection("Data Source=sakthi\\sqlexpress; Initial Catalog=LoginDetails; Integrated Security=True");
SqlCommand cmd = new SqlCommand("select * from emp where empcode ='" + txtEmpCode.Text + "'", CN);
SqlDataReader myreader;
try
{
CN.Open();
myreader = cmd.ExecuteReader();
if (myreader.Read())
{
txtEmpCode.Text = myreader[0].ToString();
txtName.Text = myreader[1].ToString();
txtGender.Text = myreader[3].ToString();
byte[] img = (byte[])(myreader[2]);
if (img == null)
pictureBox1.Image = null;
else
{
MemoryStream ms = new MemoryStream(img);
pictureBox1.Image = Image.FromStream(ms);
}
}
else
{
MessageBox.Show("do not found");
}
CN.Close();
}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
}
Reply
Answers (
2
)
using genetic algorithms to improve voice commands recogniti
object Reference not set to an instance of an Object Error