SqlCommand cmd1 = new SqlCommand("select image from audit where image=@image", con);
SqlCommand cmd = new SqlCommand("delete from audit where image=@image", con);
cmd.Parameters.Add("@image", SqlDbType.VarChar).Value = (GridView1.DataKeys[e.RowIndex].Value);
cmd1.Parameters.Add("@image", SqlDbType.VarChar).Value = (GridView1.DataKeys[e.RowIndex].Value);
con.Open();
SqlDataReader dr= cmd1.ExecuteReader();
dr.Read();
string s =Server.MapPath(dr[0].ToString());
if (File.Exists(s))
{
System.IO.File.Delete(s);
Response.Write("Deleted");
}
dr.Close();
cmd.ExecuteNonQuery();
con.Close();
bind();
No comments:
Post a Comment