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

Update Image not working

Hi all, i am having problems updateing images to db, the insert statement works fine. this is my code

Expand|Select|Wrap|Line Numbers
  1.  command = new SqlCommand("UPDATE ITEMS SET IMG_NAME='@img_name', IMG_DATA='@img_data', IMG_CONTENTTYPE='@img_contenttype', NAME='@name', CATEGORY='@cat', PRICE='@price', DERSCIPTION='@desc', QUANTITY='@quant' WHERE IMG_PK='@imgId'", connection);
  2.  
  3.  
  4.    SqlParameter param0 = new SqlParameter("@img_name", SqlDbType.VarChar, 50);
  5.                     param0.Value = imgName;
  6.                     command.Parameters.Add(param0);
  7.  
  8.                     SqlParameter param1 = new SqlParameter("@img_data", SqlDbType.Image);
  9.                     param1.Value = imgBinaryData;
  10.                     command.Parameters.Add(param1);
  11.  
  12.                     SqlParameter param2 = new SqlParameter("@img_contenttype", SqlDbType.VarChar, 50);
  13.                     param2.Value = imgContentType;
  14.                     command.Parameters.Add(param2);
  15.  
  16.                     SqlParameter param3 = new SqlParameter("@name", SqlDbType.VarChar, 50);
  17.                     param3.Value = szName;
  18.                     command.Parameters.Add(param3);
  19.  
  20.                     SqlParameter param4 = new SqlParameter("@cat", SqlDbType.Int);
  21.                     param4.Value = iCat;
  22.                     command.Parameters.Add(param4);
  23.  
  24.                     SqlParameter param5 = new SqlParameter("@price", SqlDbType.Decimal);
  25.                     param5.Value = dPrice;
  26.                     command.Parameters.Add(param5);
  27.  
  28.                     SqlParameter param6 = new SqlParameter("@desc", SqlDbType.VarChar, 300);
  29.                     param6.Value = szDesc;
  30.                     command.Parameters.Add(param6);
  31.  
  32.                     SqlParameter param7 = new SqlParameter("@quant", SqlDbType.Int);
  33.                     param7.Value = iQuantity;
  34.                     command.Parameters.Add(param7);
  35.  
  36.  SqlParameter param13 = new SqlParameter("@imgId", SqlDbType.VarChar, 25);
  37.                     param13.Value = szImgIdNew;
  38.                     command.Parameters.Add(param13);
  39.  
  40.  
  41.  
  42.  
  43.                     connection.Open();
  44.                     numRowsAffected = command.ExecuteNonQuery();
  45.                     connection.Close();

* numRowsAffected always returns 0 i checked there are no null values, thanks for your help
May 20 '10 #1
1 1767
ck9663
2,878 Expert 2GB
Display the entire SQLCommand in a window. Copy that command and paste it on a query analyzer and execute it.

See if it executes properly. We'll go from there....

Good Luck!!!

~~ CK
May 20 '10 #2

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

Similar topics

1
by: Mudcat | last post by:
I have an image that displays on a canvas that works unless I put the same code in a class. I can't figure that out. Here's what works: def uts5100(self): self.screen = Toplevel( self.master )...
3
by: brenny | last post by:
I'm saving image to any folder(no write,read permisions) by using image1.save method. I have accomplished this but I want to update this image,I want to change this image with another image or...
0
by: johnnymack0730 | last post by:
Hello - I am currently working on an asp.net application that needs to be able to update an access table using ExecuteNonQuery method. I have all the code setup, it runs, there are no errors...
5
by: HydroSan | last post by:
Having a bit of a problem getting UPDATE working. The project in question is a simple MySQL VB.NET frontend, allowing Insertion, Selection, and others. Well, I've gotten Drop and Insert working,...
1
by: stahl.karl | last post by:
I am trying to update an image when I load a page, then perform a bunch of other actions that take a while. The problem is that the image does not update until the entire function has finished...
0
by: loga123 | last post by:
Hi All, I am using asp.net 2.0. I have a gridview where I want to update a row value on clicking 'UPDATE" buttomn. I have set up sqlDataSource and UPDATE statement. When I click on UPDATE, it...
5
by: qatarya3sal | last post by:
Imports System.XML Public Class Form1 Inherits System.Windows.Forms.Form Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ...
0
jas16183
by: jas16183 | last post by:
Hi Guys, need some help here, Im working on a project in vb.net, the problem im facing is that my tableadapter.update(dataset.datatable) is not functioning, the datatable has a relation with...
1
by: nthaka1 | last post by:
Hi, I have used one HTMLEditor user control in which iframe and textarea are used. I had uploaded my html page in that editor and trying to edit html page. In this I want to give facility like...
3
by: fishnfrogs | last post by:
Hi, I can't figure out why this isn't working. I'm trying to loop through an array and do a mysql update. However, it doesn't work. for($i = 0; $i < $len; ++$i) { $param = $array . '%';...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...

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.