473,385 Members | 1,564 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,385 software developers and data experts.

Parameter Not Valid Error

mafaisal
142 100+
Hi Everybody

My Error when i Retrieve imge file from sql2005 database
parameter not valid error is coming

my code is

Dim Logo As Byte() = RsC.Fields("Logo").Value
Dim stream As System.IO.MemoryStream
stream = New System.IO.MemoryStream(Logo)
PBLogo.Image = System.Drawing.Image.FromStream(stream) - Here That error coming

Plz hep me
Jan 3 '08 #1
5 2309
Plater
7,872 Expert 4TB
The code part *seems* correct.
I would wonder if the byte array you have corrosponds to the binary data that it should. Maybe it's empty?
Jan 3 '08 #2
Frinavale
9,735 Expert Mod 8TB
Hi Everybody

My Error when i Retrieve imge file from sql2005 database
parameter not valid error is coming

my code is

Dim Logo As Byte() = RsC.Fields("Logo").Value
Dim stream As System.IO.MemoryStream
stream = New System.IO.MemoryStream(Logo)
PBLogo.Image = System.Drawing.Image.FromStream(stream) - Here That error coming

Plz hep me
Check to make sure that the value you retrieve from your database contains data:
ArgumentException: The stream does not have a valid image format -or- stream is a null reference (Nothing in Visual Basic). (Image.FromStream Method)

-Frinny
Jan 3 '08 #3
Torgg
41
This is the code I use for my header Image. There might be a better/cleaner way to get this done but this has worked well for me.

Expand|Select|Wrap|Line Numbers
  1.  
  2. public byte[] LogoRetrieve()
  3.         {
  4.             //Gets the image from the database and returns a byte array 
  5.             SqlConnection sqlConn = new SqlConnection(Properties.Settings.Default.ConnectionString);
  6.  
  7.             DataTable dtImages = new DataTable();
  8.             using (sqlConn)
  9.             {
  10.                 try
  11.                 {
  12.                     sqlConn.Open();
  13.                     SqlCommand sqlComm = sqlConn.CreateCommand();
  14.  
  15.                     //Select Image
  16.                     sqlComm.CommandText = "SELECT HeaderLogo FROM dbo.ConfigurationSettings WHERE ConfigID = 1";
  17.                     sqlComm.ExecuteNonQuery();
  18.  
  19.                     SqlDataAdapter sqlDA = new SqlDataAdapter(sqlComm);
  20.                     sqlDA.Fill(dtImages);
  21.                 }
  22.                 catch (Exception ex)
  23.                 {
  24.                     MessageBox.Show(Convert.ToString(ex));
  25.                 }
  26.                 finally
  27.                 {
  28.                     sqlConn.Close();
  29.                 }
  30.             }
  31.  
  32.             //Get image from the DataTable
  33.             byte[] imageData = (byte[])dtImages.Rows[0]["HeaderLogo"];
  34.  
  35.             return imageData; 
  36.         }
I hope this is helpful,
Torgg
Jan 4 '08 #4
mafaisal
142 100+
This is C#
Plz Give vb.net code

also byte array not empty

plz

This is the code I use for my header Image. There might be a better/cleaner way to get this done but this has worked well for me.

Expand|Select|Wrap|Line Numbers
  1.  
  2. public byte[] LogoRetrieve()
  3.         {
  4.             //Gets the image from the database and returns a byte array 
  5.             SqlConnection sqlConn = new SqlConnection(Properties.Settings.Default.ConnectionString);
  6.  
  7.             DataTable dtImages = new DataTable();
  8.             using (sqlConn)
  9.             {
  10.                 try
  11.                 {
  12.                     sqlConn.Open();
  13.                     SqlCommand sqlComm = sqlConn.CreateCommand();
  14.  
  15.                     //Select Image
  16.                     sqlComm.CommandText = "SELECT HeaderLogo FROM dbo.ConfigurationSettings WHERE ConfigID = 1";
  17.                     sqlComm.ExecuteNonQuery();
  18.  
  19.                     SqlDataAdapter sqlDA = new SqlDataAdapter(sqlComm);
  20.                     sqlDA.Fill(dtImages);
  21.                 }
  22.                 catch (Exception ex)
  23.                 {
  24.                     MessageBox.Show(Convert.ToString(ex));
  25.                 }
  26.                 finally
  27.                 {
  28.                     sqlConn.Close();
  29.                 }
  30.             }
  31.  
  32.             //Get image from the DataTable
  33.             byte[] imageData = (byte[])dtImages.Rows[0]["HeaderLogo"];
  34.  
  35.             return imageData; 
  36.         }
I hope this is helpful,
Torgg
Jan 13 '08 #5
mafaisal
142 100+
Hello Plater
I am Saving image in database as datatype image in sql2005
i have to retrieve that image then these error coming
also it is not empty
i trying to retrieve in picturebox pblogo



The code part *seems* correct.
I would wonder if the byte array you have corrosponds to the binary data that it should. Maybe it's empty?
Jan 13 '08 #6

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

Similar topics

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...
1
by: Joost Kraaijeveld | last post by:
Hi all, In my application that is generated by Clarion an SQL0418N ("A statement contains a use of a parameter marker that is not valid.") occurs. In the explanation section it says "in some...
4
by: Andy Davis | last post by:
I have developed a number of reports that are based on parameter queries where the user enters criteria such as a date range and a sales rep say. I want to be able to show a graphical picture in...
4
by: Ondrej Spanel | last post by:
The code below does not compile with .NET 2003, I get folowing error: w:\c\Pokusy\delegTemplArg\delegTemplArg.cpp(11) : error C2993: 'float' : illegal type for non-type template parameter 'x' ...
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...
4
by: Martin Evans | last post by:
Hi, I'm getting: DBD::DB2::db do failed: SQL0440N No authorized routine named "CONCAT" of type "FUNCTION" having compatible arguments was found. SQLSTATE=42884 for some SQL like this:
1
by: Racerx | last post by:
HI All, I use db2 v8.1 on AIX 5.2 I recieve the following message in my DIAGLOG after evry instance restart. 2007-02-09-03.39.17.201881 Instance:db2inst1 Node:000 PID:639190(db2bp) ...
7
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
I have an image which I'm trying to save using my_image.Save(some_path, System.Drawing.Imaging.ImageFormat.Path); and then I get the error "Parameter is not valid". What could be the reason...
9
by: JRough | last post by:
I'm getting the error message that the parameter passed to the function is not a valid resource. The parameter is $result and it is from a query in a switch statement. What do I have to do to get...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?

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.