Solved

delete image from sql in ado.net

Posted on 2006-07-04
8
244 Views
Last Modified: 2010-04-16
hi there ,

i want to delete image from sql server 2000 ?

i have try this code :

                                                      dbCmd.CommandType = CommandType.Text;
                        dbCmd.CommandText = "update CustDet set logo="+DBNull.Value;
                        dbCmd.Parameters.Clear();
                                  dbCmd.Connection.Open();
                        dbCmd.ExecuteNonQuery();
                        dbCmd.Connection.Close();
but its dosent work ...
how can i remove image from sql ?
thanks....
0
Comment
Question by:Tech_Men
  • 4
  • 3
8 Comments
 
LVL 6

Assisted Solution

by:so3
so3 earned 100 total points
ID: 17038174
Did you try this?  not tested

      dbCmd.CommandType = CommandType.Text;
      dbCmd.CommandText = "update CustDet set logo=NULL";
      dbCmd.Parameters.Clear();
      dbCmd.Connection.Open();
      dbCmd.ExecuteNonQuery();
      dbCmd.Connection.Close();

and also you have to use a primery key to update only the image you want. Your code will update all the rows.
e.g
      dbCmd.CommandText = "update CustDet set logo=NULL WHERE [id]=50";
0
 

Author Comment

by:Tech_Men
ID: 17038649
its not working
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 150 total points
ID: 17038919
I am just curious why you are updating ... I thought you said you wanted to delete it?

Generally to delete a row someone would execute a command such as

DELETE FROM CustDet where [id] = 222

When you say it doesn't work what happens .. perhaps we can help you figure it out but we will need some more information as there are many reasons why the statement may not work. If the code is throwing an exception, that exception would help alot in figuring out whats going on. If it is not throwing an exception what are the pre/post conditions, what is the statement being executed, and lastly what is the expected/observed behavior?

Cheers,

Greg Young
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:Tech_Men
ID: 17038957
this is the code :

connection.ConnectionString = BL.Conn.ConnString();
                        dbCmd.Connection = connection;

                        dbCmd.CommandType = CommandType.Text;
                        dbCmd.CommandText = "DELETE logo FROM CustDet where CustDetRunID=4";
                                                

                                                      

                        dbCmd.Connection.Open();
                        dbCmd.ExecuteNonQuery();
                        dbCmd.Connection.Close();
not working
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 17038962
<quote>
When you say it doesn't work what happens .. perhaps we can help you figure it out but we will need some more information as there are many reasons why the statement may not work. If the code is throwing an exception, that exception would help alot in figuring out whats going on. If it is not throwing an exception what are the pre/post conditions, what is the statement being executed, and lastly what is the expected/observed behavior?
</quote>
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 17038975
also you don't

DELETE logo .. delete deletes the entire row...

it would just be

"DELETE FROM CustDet where CustDetRunID=4";
0
 

Author Comment

by:Tech_Men
ID: 17038989
but it will delete all i want to delete only the logo (image)
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 17039011
ok then you want to update (as I had said in your post you said that you wanted to delete it so there was confusion as to what you were trying to do). Now if you want further help you will need to provide other information (as I described above). Your update could not be working for many reasons .. The further information will let us know which reason it is not working.

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What is "public object" in C#? 3 66
Winform Module - What is the ASP.Net equiv 2 28
Expression Evaluater 3 38
jquery + C#.net radiobuttonlist 3 30
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question