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
IFAR AKR
NA
17
2.2k
How to display the image to picturebox from sql server2008
Nov 11 2016 3:28 PM
private void button5_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=RAFIUDDEEN-PC\\SQLEXPRESS;Initial Catalog=MKH;Integrated Security=True");
try
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter();
string sql = "Select *from Detail where Roll_Number='" + textBox2.Text + "'";
SqlCommand cmd = new SqlCommand(sql, con);
if (con.State != ConnectionState.Open)
con.Open();
cmd.ExecuteNonQuery();
SqlDataReader dr = cmd.ExecuteReader();
DataSet ds = new DataSet();
DataRow rrw;
while (dr.Read())
{
if (dr.HasRows)
{
string Name = dr.GetString(1);
textBox6.Text = dr.GetDateTime(5).ToShortDateString();
string Admission_Number = dr.GetString(3);
string Class = dr.GetString(4);
string Mother_Tongue = dr.GetString(6);
string Academic_Year = dr.GetString(10);
string Father_Name = dr.GetString(11);
string Email_ID = dr.GetString(7);
string Address = dr.GetString(12);
string City = dr.GetString(13);
string State = dr.GetString(14);
textBox12.Text = dr.GetDateTime(9).ToShortDateString();
string Pin_code = dr.GetInt32(15).ToString();
string Phone = dr.GetString(16);
textBox1.Text = Name;
textBox3.Text = Admission_Number;
comboBox1.Text = Class;
comboBox2.Text = Mother_Tongue;
comboBox3.Text = Academic_Year;
textBox11.Text = Father_Name;
textBox4.Text = Email_ID;
textBox5.Text = Address;
textBox7.Text = City;
textBox8.Text = State;
textBox9.Text = Pin_code;
textBox10.Text = Phone;
byte[] Photo = (byte[])(dr[8]);
if (Photo == null)
pictureBox1.Image = null;
else
{
MemoryStream ms = new MemoryStream(Photo);
pictureBox1.Image = Image.FromStream(ms);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
con.Close();
}
Every one pls help me!! Photo are not showing in the Picturebox...Showing the messagebox Paramter are not valid... How will be solved..??
Attachment:
Images_error.rar
Reply
Answers (
4
)
how to call insert update method in console or client applic
timer use in traffic signal. in c#