如何从asp.net c中的表和文件夹中删除相关记录和图像 [英] How to delete related records and images from the tables and folder in asp.net c#
问题描述
i有两个表存储图像路径,图像存储在一个文件夹中,
table1
------
pid int
pname nvarchar(50)
pimages nvarchar (最多)
-----------------------------------
table2
------
fid int,主键
fname nvarchar(50)
fimage nvarchar(max)
pid int
------------------------ ----------
第一张表中的每张图片与第二张图片中的图片相关
(一对多的关系)
我想从第一张表中删除图片,删除第二张图片的图像,图片也从文件夹中删除。
任何帮助.... ^ _ ^
谢谢。
Hi,
i have two tables stored images path, and images are stored in a folder,
table1
------
pid int
pname nvarchar(50)
pimages nvarchar(max)
-----------------------------------
table2
------
fid int , primary key
fname nvarchar(50)
fimage nvarchar(max)
pid int
----------------------------------
each image from the first table related with the images from the second table
( one to many relationship )
I want when delete the image from the first table, delete with its images of the second table and the images also delete from the folder .
any help.... ^_^
Thanks.
推荐答案
从table1,table2中删除pid = YourID
我不确定但是嘘可以工作。
如果你要从C#中删除它,那么当用户点击删除按钮时会传递你的ID。并在上面的SQL Query中使用该ID。
Delete from table1,table2 where pid= YourID
I am not sure but It should work.
If you are deleting it from C# then pass your ID when user click on delete button. and Use that ID in above SQL Query.
这篇关于如何从asp.net c中的表和文件夹中删除相关记录和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!