473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Parameter is not valid

String qry;
qry = "select gpid, image_url from g_product_specific order by gpid";
SqlDataAdapter da = new SqlDataAdapter(qry, con);
DataSet ds = new DataSet();
da.Fill(ds);


// convert string to bytes
System.Text.Encoding enc = System.Text.Encoding.ASCII;
byte[] myByteArray = enc.GetBytes(ds.Tables[0].Rows[0]["image_url"].ToString());

System.IO.MemoryStream ms = new System.IO.MemoryStream(myByteArray);

System.Drawing.Image img = System.Drawing.Image.FromStream(ms); // Error occurs here. "parameter is not valid"
string ImageName = "abc.jpg";
string dipath = HttpRuntime.AppDomainAppPath + "My Images\\";
string serverPath = dipath + ImageName;
img.Save(serverPath);


I'm trying to download image url in database to image file to the local folder. i tried for past two days. I struggle with this. If anybody face this problem and got soultion, revert me back.

Thanks in advance.
Dec 6 '07 #1
2 1075
Shashi Sadasivan
1,435 Expert 1GB
String qry;
qry = "select gpid, image_url from g_product_specific order by gpid";
SqlDataAdapter da = new SqlDataAdapter(qry, con);
DataSet ds = new DataSet();
da.Fill(ds);


// convert string to bytes
System.Text.Encoding enc = System.Text.Encoding.ASCII;
byte[] myByteArray = enc.GetBytes(ds.Tables[0].Rows[0]["image_url"].ToString());

System.IO.MemoryStream ms = new System.IO.MemoryStream(myByteArray);

System.Drawing.Image img = System.Drawing.Image.FromStream(ms); // Error occurs here. "parameter is not valid"
string ImageName = "abc.jpg";
string dipath = HttpRuntime.AppDomainAppPath + "My Images\\";
string serverPath = dipath + ImageName;
img.Save(serverPath);


I'm trying to download image url in database to image file to the local folder. i tried for past two days. I struggle with this. If anybody face this problem and got soultion, revert me back.

Thanks in advance.
FromStream requires a parametr of type System.IO.Stream.
The parameter ms being passed is of System.IO.MemoryStream type.
that would be the probable cause.
Dec 6 '07 #2
FromStream requires a parametr of type System.IO.Stream.
The parameter ms being passed is of System.IO.MemoryStream type.
that would be the probable cause.
Hi Shashi,

I tried, what you said. But i got same error message.
Dec 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: muser | last post by:
How can I pass the parameter " long part_num, into a case statement. Case statement follows the function CheckDigit. i.e. CheckDigit( something, temp1 ); Thank you for your help in advance. ...
4
by: wkaras | last post by:
I would like to propose the following changes to the C++ Standard, the goal of which are to provide an improved ability to specify the constraints on type parameters to templates. Let me say from...
4
by: Todd Perkins | last post by:
Hello all, surprisingly enough, this is my first newsgroup post, I usually rely on google. So I hope I have enough info contained. Thank you in advance for any help! Problem: I am getting...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
7
by: George | last post by:
Hi, Does anyone know how Control.Invoke can invoke a method which has ref parameters? For example, class A { public delegate MyFuncHandler(ref int i, ref int j);
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.