Subject: Resimler tablosundan ürüne ait fotoğrafları silmek
Posted: 06 Mart 2018 at 20:07
Ürünler tablom var. URUNID li.
if (texturunsilid.Text != "")
{
try
{
DataRow resimA = klas.GetDataRow("Select * from RESIMLER Where URUNID='" + texturunsilid.Text + "'");
FileInfo FiresimA = new FileInfo(Server.MapPath("../" + resimA["RESIM"].ToString()));
FiresimA.Delete();
}
catch (Exception)
{
}
sqlbaglantisi baglan = new sqlbaglantisi();string sqlsorgu = "delete from URUNLER where URUNID='" + texturunsilid.Text + "'";
SqlCommand sil = new SqlCommand(sqlsorgu, baglan.baglan());
int a = sil.ExecuteNonQuery();
if (a > 0)
{
Labelurunsilmesaj.Text = "Seçilen ÜRÜN silindi.";
texturunsilid.Text = "";
}
else
{
Labelurunsilmesaj.Text = "Kayıt bulunamadı.";
texturunsilid.Text = "";
}
}