Frågan#1
Jag ska ta bort en katalog och alla underkataloger samt sidorna som ligger i katalogerna.
Så här ser min kod ut nu, går det att göra enklare?
If action = "DELETEFOLDER" and isNumeric(actionFolderID) Then
Function getCatalogs(Byval actionOpenFolder, Byref strActionFolders)
Set checksystemFoldersRs = Con.Execute("Select folderID from folders where folderParent = "& actionOpenFolder)
While not checksystemFoldersRs.Eof
strActionFolders = strActionFolders&checksystemFoldersRs("folderID")&","
call getCatalogs(checksystemFoldersRs("folderID"), strActionFolders)
checksystemFoldersRs.MoveNext
Wend
checksystemFoldersRs.Close : Set checksystemFoldersRs = Nothing
End Function
call getCatalogs(actionFolderID, strActionFolders)
sqlString = "Select sida_id from sidor Where (sida_typ = 1 or sida_typ= 2) And (sida_folderID = "& actionFolderID
If strActionFolders <> "" Then
strActionFolders = left(strActionFolders, (len(strActionFolders)-1))
arrActionFolders = split(strActionFolders, ",")
For i=0 To ubound(arrActionFolders) step 1
sqlString = sqlString & " Or sida_folderID = "& arrActionFolders(i)
Next
End If
sqlString = sqlString&")"
Set checksystemPagesRS = Con.Execute(sqlString)
If not checksystemPagesRS.Eof Then
errorMessage = "Mappen innehåller en systemsida och kan ej tas bort!"
End If
checksystemPagesRS.close : set checksystemPagesRS = nothing
If errorMessage = "" Then
sqlString = "Delete from sidor Where sida_folderID = "& actionFolderID
If strActionFolders <> "" Then
For i=0 To ubound(arrActionFolders) step 1
sqlString = sqlString & " Or sida_folderID = "& arrActionFolders(i)
Next
End If
Con.Execute(sqlString)
sqlString = "Delete from folders Where folderID = "& actionFolderID
If strActionFolders <> "" Then
For i=0 To ubound(arrActionFolders) step 1
sqlString = sqlString & " Or folderID = "& arrActionFolders(i)
Next
End If
Con.Execute(sqlString)
Else
errorMessage = "Mappen innehåller en systemsida och kan ej tas bort!"
End If
End If