Solved

delete image from sql in ado.net

Posted on 2006-07-04
8
240 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
 

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now