Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
below is my code.

in my table i have filename and id.the code below can delete filename in table but it cannot delete the image that saves in folder..Please help..

C#
protected void deleteImage_Click(object sender, EventArgs e)
    {
       
        string strConnString = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(strConnString);
        conn.Open();
        SqlCommand cmd = new SqlCommand("Delete From ImageTbl Where id= '" + txt_delete.Text + "'", conn);
        cmd.ExecuteNonQuery();
        conn.Close();
        bindgrid();
        txt_delete.Text = "";
        txt_delete.Focus();
    }
Posted
Updated 23-May-13 8:58am
v2

1 solution

 
Share this answer
 
Comments
brighteyes24 23-May-13 15:21pm    
SomeFile.txt is a fix file that to be deleted..what if the user upload another image file, another filename..?and i want to delete the new image filename that has been uploaded..
Maciej Los 23-May-13 15:26pm    
Probably, you store the path to the picture in your database. Fetch this value to a string variable and delete file (image).
brighteyes24 23-May-13 15:34pm    
can you give me codes for this sir?
Maciej Los 23-May-13 15:38pm    
In which part? How can i help you, if i don't know the structure of your database?
brighteyes24 23-May-13 15:46pm    
I have folder name Images.all photo or images uploaded will store in the Images folder..of course different filename are uploaded..now if i want to delete that particular account and remove also the photo that save in Images folder..how can it be?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900