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
Sengouttuvelu Muthusamy
NA
62
2.9k
System.ArgumentException: Parameter is not valid.
Jun 29 2015 3:42 AM
Hi am storing images in sql server. The datatype is Image.
while retrieving the Images from the database i getting error like System.ArgumentException: Parameter is not valid.
The error coming in this line "img = Image.FromStream(ms)".
private void RetriveImage_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(constr);
con.Open();
Image img;
try
{
cmd = new SqlCommand("select Pic from emguimg where ID =" + cbxID.SelectedItem.ToString() + "", con);
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dr);
byte[] bytes = (byte[])((byte[])dt.Rows[0]["Pic"]);
MemoryStream ms = new MemoryStream(bytes);
ms.Write(bytes, 0, bytes.Length);
img = Image.FromStream(ms);
PicBox.Image = img;
PicBox.SizeMode = PictureBoxSizeMode.StretchImage;
PicBox.BorderStyle = BorderStyle.Fixed3D;
ms.Flush();
ms.Close();
}
catch(Exception ex)
{
WriteLogMessage(ex.ToString());
}
}
Reply
Answers (
4
)
Update and Reset Password in MVC without using Membership
Copy specific Column data from one datatable to another