473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

FSO with Database

F
Hi all

I have some difficulty to manage FSO with Database.

Actually I am building a tree view of user files and folders.

I have saved record of each file and folder with its parent id in a table
for example

Table
------------------
Name --ID--ParentID
-------------------
Root--1--0
Mydoc--2--1
Mypic--3--2
songs--4--2
mov--5--2
eng--6--5
ger--7--5
fra--8--5
engus--9--6
enguk--10--6
mp3--11--2
wm--12--2
--------------------
If I delete folder name ="mov" ID="5" ParentID=2. I have to delete

1. Physically from hard disk folder name = "mov" (and all its child will be
deleted automatically)
2. All records from table which related to this folder so record no with ID
6,7,8,9,10 should be deleted from table.

But I am facing difficulty with deleting records 6,7,8,9,10 as dont have
idea to get these IDs

Any advise from ASP gurus.

Regards
Fayayz
Jul 19 '05 #1
5 1561
DELETE table WHERE ParentID = 5
OR ParentID IN (SELECT ID FROM table WHERE ParentID = 5)

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"F@yy@Z" <fa**********@mvwebmaker.com> wrote in message
news:O5**************@TK2MSFTNGP12.phx.gbl...
Hi all

I have some difficulty to manage FSO with Database.

Actually I am building a tree view of user files and folders.

I have saved record of each file and folder with its parent id in a table
for example

Table
------------------
Name --ID--ParentID
-------------------
Root--1--0
Mydoc--2--1
Mypic--3--2
songs--4--2
mov--5--2
eng--6--5
ger--7--5
fra--8--5
engus--9--6
enguk--10--6
mp3--11--2
wm--12--2
--------------------
If I delete folder name ="mov" ID="5" ParentID=2. I have to delete

1. Physically from hard disk folder name = "mov" (and all its child will
be
deleted automatically)
2. All records from table which related to this folder so record no with
ID
6,7,8,9,10 should be deleted from table.

But I am facing difficulty with deleting records 6,7,8,9,10 as dont have
idea to get these IDs

Any advise from ASP gurus.

Regards
Fayayz

Jul 19 '05 #2
F
Thanks for immidiate reply.

What about record no 9,10 and what if some record have parent ID 9 or 10 and
if that have more childs.

Please look into this and advise.

regards

Fayyaz
"Aaron Bertrand [MVP]" <aa***@TRASHaspfaq.com> wrote in message
news:OJ**************@tk2msftngp13.phx.gbl...
DELETE table WHERE ParentID = 5
OR ParentID IN (SELECT ID FROM table WHERE ParentID = 5)

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"F@yy@Z" <fa**********@mvwebmaker.com> wrote in message
news:O5**************@TK2MSFTNGP12.phx.gbl...
Hi all

I have some difficulty to manage FSO with Database.

Actually I am building a tree view of user files and folders.

I have saved record of each file and folder with its parent id in a table for example

Table
------------------
Name --ID--ParentID
-------------------
Root--1--0
Mydoc--2--1
Mypic--3--2
songs--4--2
mov--5--2
eng--6--5
ger--7--5
fra--8--5
engus--9--6
enguk--10--6
mp3--11--2
wm--12--2
--------------------
If I delete folder name ="mov" ID="5" ParentID=2. I have to delete

1. Physically from hard disk folder name = "mov" (and all its child will
be
deleted automatically)
2. All records from table which related to this folder so record no with
ID
6,7,8,9,10 should be deleted from table.

But I am facing difficulty with deleting records 6,7,8,9,10 as dont have
idea to get these IDs

Any advise from ASP gurus.

Regards
Fayayz


Jul 19 '05 #3
How many levels do you allow? You will have to run that many subqueries, I
think. Or, add a column indicating TOP and delete where top = 5.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"F@yy@Z" <fa**********@mvwebmaker.com> wrote in message
news:O3****************@TK2MSFTNGP09.phx.gbl...
Thanks for immidiate reply.

What about record no 9,10 and what if some record have parent ID 9 or 10
and
if that have more childs.

Please look into this and advise.

regards

Fayyaz

Jul 19 '05 #4
F
There is no limit of levels, and If I put a column "TOP" what about if some
one delete any child of this top.

This is very strange situation :(

"Aaron Bertrand [MVP]" <aa***@TRASHaspfaq.com> wrote in message
news:u5**************@TK2MSFTNGP12.phx.gbl...
How many levels do you allow? You will have to run that many subqueries, I think. Or, add a column indicating TOP and delete where top = 5.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"F@yy@Z" <fa**********@mvwebmaker.com> wrote in message
news:O3****************@TK2MSFTNGP09.phx.gbl...
Thanks for immidiate reply.

What about record no 9,10 and what if some record have parent ID 9 or 10
and
if that have more childs.

Please look into this and advise.

regards

Fayyaz


Jul 19 '05 #5
Trees with unlimited levels are always tricky. The key is in when you
actually store the record, and not as much in SQL script itself. Consider
using an additional column of text type. Here's an example

Folder ID Parent CompositeParentKey
---------------------------------------
FolderA 1 0 0/
FolderB 2 1 0/1/
FolderC 3 2 0/1/2/
FolderD 4 2 0/1/2/
FolderX 5 3 0/1/2/3/
FolderY 6 3 0/1/2/3/
FolderI 8 6 0/1/2/3/6/
FolderJ 9 6 0/1/2/3/6/

If you notice, the composite is basically = Parent Composite Parent Key +
ParentKey + "/"

so for FolderC, the compositeParentKey is "0/1/" + 2 + "/"

You need to establish this key when you first write the record out. So, it
is a little work upfront, but makes your life easier later.

Consider you want to delete FolderC, you also need to delete folderX and
folderY. The way you do this is, for folderC, get the CompositeParenKey +
its own key

Key = "0/1/2/" + 3 + "/"

Now, delete all folders that have this to begin

DELETE FROM Folders WHERE CompositeParentKey LIKE '0/1/2/3/%'

And then delete FolderC itself. Hope this helps.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"F@yy@Z" <fa**********@mvwebmaker.com> wrote in message
news:O5**************@TK2MSFTNGP12.phx.gbl...
Hi all

I have some difficulty to manage FSO with Database.

Actually I am building a tree view of user files and folders.

I have saved record of each file and folder with its parent id in a table
for example

Table
------------------
Name --ID--ParentID
-------------------
Root--1--0
Mydoc--2--1
Mypic--3--2
songs--4--2
mov--5--2
eng--6--5
ger--7--5
fra--8--5
engus--9--6
enguk--10--6
mp3--11--2
wm--12--2
--------------------
If I delete folder name ="mov" ID="5" ParentID=2. I have to delete

1. Physically from hard disk folder name = "mov" (and all its child will b e deleted automatically)
2. All records from table which related to this folder so record no with ID 6,7,8,9,10 should be deleted from table.

But I am facing difficulty with deleting records 6,7,8,9,10 as dont have
idea to get these IDs

Any advise from ASP gurus.

Regards
Fayayz

Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Cherrish Vaidiyan | last post by:
sir, The following are the steps that i followed in setting up standby database on Red hat Linux 9. i am using Oracle 9i. i have followed the steps in this site : ...
6
by: Marvin Libson | last post by:
Hi All: I am running DB2 UDB V7.2 with FP11. Platform is Windows 2000. I have created a java UDF and trigger. When I update my database I get the following error: SQL1224N A database...
8
by: Kamlesh | last post by:
Hi, How do I know the physical database path of a database. When I goto the DB2INSTANCE users's directory (/home/db2inst1), I see following folders: /db2inst1/NODE0000/SQL00001...
1
by: pintur | last post by:
The message is: SQL1036C Errore di I/O durante l' accesso al database. SQLSTATE=58030 what is the proble? what for restore tables? thanks
3
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news...
8
by: morleyc | last post by:
Hi, until recently i was quite happy to add data sources from mssql database in visual studio and drag the datasets directly onto the form this creating a directly editable form which worked well....
0
by: Jack | last post by:
Training Classes for Oracle10g, 9i, 8i Certification training in Oracle10g and 9i: DBA, Developer, Discoverer. training conducted at your location worldwide. Courseware licensing also available....
0
by: Winder | last post by:
Training Classes for Oracle10g, 9i, 8i Certification training in Oracle10g and 9i: DBA, Developer, Discoverer. training conducted at your location worldwide. Courseware licensing also available....
0
by: Laurynn | last post by:
# (ebook - pdf) - programming - mysql - php database applicati # (Ebook - Pdf)Learnkey How To Design A Database - Sql And Crystal Report # (ebook-pdf) E F Codd - Extending the Database Relational...
9
by: Peter Duniho | last post by:
Is there a straightfoward API in .NET that allows for inspection of a database? That is, to look at the structure of the database, without knowing anything in advance about it? For example,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.