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
saifullah khan
NA
335
301.8k
Parameter is not valid.
Oct 27 2011 6:14 AM
i have a ppt file which i have converted from ppt to image and then save it in db. it save successfully. then i retrieve it from db but it gives and error:
parameter is not valid
Image imag = Image.FromStream(stream);
here is the code for saving in db:
protected void Button1_Click(object sender, EventArgs e)
{
ApplicationClass pptApplication = new ApplicationClass();
Presentation pptPresentation = pptApplication.Presentations.Open("saifullah.ppt", MsoTriState.msoFalse,
MsoTriState.msoFalse, MsoTriState.msoFalse);
var slides = new List<string>();
for (var i = 1; i <= pptPresentation.Slides.Count; i++)
{
string target = i+".jpeg".ToString();
pptPresentation.Slides[i].Export(target, "jpg", width, height);
string pic = target;
con.Open();
cmd = new SqlCommand("insert into images values('"+@pic+"')",con);
cmd.ExecuteNonQuery();
con.Close();
}
pptPresentation.Close();
}
and here is for retreiving from db.
MemoryStream stream = new MemoryStream();
try
{
con.Open();
cmd = new SqlCommand("select pics from images", con);
byte[] image = (byte[])cmd.ExecuteScalar();
stream.Write(image, 0, image.Length);
Image imag = Image.FromStream(stream);
Response.ContentType = "image/JPEG";
imag.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
finally
{
con.Close();
stream.Close();
}
please tell me what i need to correct
Reply
Answers (
19
)
how to get records faster using AutoCompleteExtender ?
how to make list like effect in csharp