Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

delete image from sql in ado.net

Posted on 2006-07-04
8
Medium Priority
?
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 6

Assisted Solution

by:so3
so3 earned 400 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 600 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

704 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