473,668 Members | 2,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

retrieve blob picture from mysql database c#

1 New Member
I use this code to retrieve my picture and it work corectly with a simple table that contain only blob but when i'm trying to adapt it for my table user that containt (cin,nom,prenom ....,image) exception that indicate

"Paramétre non valid" (not a valid parameter)
Expand|Select|Wrap|Line Numbers
  1.         int bufferSize = 1000; 
  2.         try
  3.         {
  4.             string SQL = "Select image from user ";
  5.  
  6.             MySqlCommand cmd = new MySqlCommand(SQL, db.Connection);
  7.             MySqlDataAdapter da = new MySqlDataAdapter(cmd);
  8.             DataSet ds = new DataSet();
  9.             da.Fill(ds, "image");
  10.             int c = ds.Tables["image"].Rows.Count;
  11.             db.CloseConnection();
  12.  
  13.             if (c > 0)
  14.             {
  15.                 Byte[] byteBLOBData = new Byte[bufferSize];
  16.                 byteBLOBData = (Byte[])(ds.Tables["image"].Rows[c - 1]["image"]);
  17.                 MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);
  18.  
  19.                 pictureBox1.Image = Image.FromStream(stmBLOBData);
  20.                 MessageBox.Show("bien chargée");
  21.             }
  22.  
  23.         }
  24.         catch (Exception ex)
  25.         {
  26.             MessageBox.Show("Connection Error!\n" + ex.Message, "Error Message",
  27.                     MessageBoxButtons.OK, MessageBoxIcon.Error);
  28.         }
Feb 29 '16 #1
1 8420
madankarmukta
308 Contributor
May I please know at which line it is giving an error ?
Mar 26 '16 #2

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

Similar topics

2
16787
by: webmechanic | last post by:
I was able to insert images into mysql stored as binary data. How do I retrieve it. Please provide thorough explanation. Thanks.
2
5218
by: Waqas.L.Khan | last post by:
Hi Guys, I'm doing some work with richtextboxes and want to be able to save and load the content from them to a mysql database (including all formatting). I figured the best way to do this would be to save the contant of the rtb to an rtf file and then load the file into a mysql BLOB field: Public Sub savetoDB()
1
6776
by: viresh | last post by:
Hello everybody, I am quite beginner as a software professional in php & mysql. I want to know how I can fetch data from mysql database to show in a form's drop down box with php coding. I request all to help me in this regard. Sincerely, Vireshwar, ...
2
12720
by: sarah aziz | last post by:
Hello all I am trying to retrieve the data from mysql database by php to plot a flot graph can anyone help me please this is all i have done for now Php $sql = mysql_query("SELECT count(Msg_ID) msgCount,Group_ID FROM Messages GROUP BY Group_ID"); $dataset1 = array();
0
1713
by: Kim Charlene | last post by:
Hi, guys! I've created a java servlet where I can upload video with limited size. The video uploaded is being saved in the mySQL database as BLOB. How can I retrieve that BLOB and display it as the video in my webpage? I'm new to this so I'll need all the help and guidelines you guys can give me. Thank you very much in advance. Below is my servlet code: package Projects; import java.io.IOException; import java.io.PrintWriter; import...
3
35395
by: nehpets | last post by:
this is the code that i tried to make but its not working..nothing happen to the output..i need some help..please..i am a beginner in c#....thanks!!! private void button1_Click(object sender, EventArgs e) { string input = textBox3.Text; connectdatabase(); string wow = "SELECT `CustomerName` FROM `CustomerInfo`"; MySqlCommand wowcmd = new MySqlCommand(wow, connection); ...
3
4749
by: ossama louiss | last post by:
hi evryone i want to know how to convert a blob to string i tried some solution but it keeps show the result like this .
3
1435
by: Ruchi choudhary | last post by:
Hello, What I want to do is I would like to populate dropdown menus with options from the database (e.g. file no, I would like to populate). The code seems to currently show a dropdown menu and a submit button. The dropdown menu is populated but by clicking on submit button it can't retrieve. Hope so you understand my problem. Thanks! popl.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ...
0
1753
by: impin | last post by:
i have table cresults. email marks last_submit pooja23@gmail.com 9 2013-05-24 rajletsgetlost@gmail.com 5 2013-05-24 romancingtherain@gmail.com 5 2013-05-24 vidhya.vs@gmail.com 8 2013-05-24
0
8378
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8890
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8791
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8577
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8653
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7398
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2786
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.