請讓我知道,如果我可以使問題更容易理解,因爲我可以真正的幫助做...SQL幫助有選擇選項
我們有類別和別名目錄,和我m試圖添加創建別名的能力子類進入頂級類別,其中目前我們只能將別名子類別添加到其他子類別,這不是我們想要的。
例如,我想補充的子類別「地產代理」到兩個主要類別「家居與園藝」和「金融與抵押貸款」。
我只能將'地產代理'添加到任一子類別中,所以想要在下拉選擇選項中包含頂級類別以及子類別。希望是有道理的!
該代碼發佈在下方,由2個獨立的文件組成,用於處理數據。它當前正在請求PGID - 這是父目錄GID - 即頂級類別。
我們希望別名下拉選擇選項不僅顯示屬於父類別(PGID)頂級類別的子類別(GID),還顯示PGID頂級類別本身。
E.g.選擇選項包括所有級別的類別,如:
- 家庭和花園(PGID)
- 地產代理(GID)
- 傢俱供應商(GID)
- 花園中心(GID )等
不只是:
- 地產代理(GID)
- 傢俱供應商(GID)
- 花園中心(GID)
請讓我知道如果我能進一步明確,因爲它很簡單,但難以解釋!
AddAlias.asp
<!--#include virtual="/Admin/FranchiseAdmin/DirectorySetup/Aliases/i_Alias.asp"-->
<%
objConn.Open strConn
%>
<input type="hidden" **name="PGID" value="<% = Request("PGID") %>"** />
<select>
<%
SQLCommand = "SELECT * FROM Directories WHERE GID='" & CleanSQLText(Request("PGID")) & "'"
rsTemp.Open SQLCommand, objConn, adOpenStatic, adLockReadOnly
if rsTemp.RecordCount <> 1 then
FailSystemEvent "AddAlias: Failed to load Existing Parent"
Else
%>
<option value="<% = rsTemp("GID") %>"><% = rsTemp("DirectoryName") %></option><%
End if
rsTemp.Close
SQLCommand = "SELECT * FROM Directories WHERE ParentDirectoryGID IS NOT NULL AND GID <> '" & CleanSQLText(Request("PGID")) & "' ORDER BY DirectoryName"
rsTemp.Open SQLCommand, objConn, adOpenStatic, adLockReadOnly
While Not rsTemp.EOF
CreateSelectOption rsTemp("GID"), rsTemp("DirectoryName"), CleanSQLText(Request("PGID"))
rsTemp.MoveNext
Wend
rsTemp.Close
%>
</select>
<%
objConn.Close
%>
我去掉上面的代碼ParentDirectoryGID IS NOT NULL
現在在哪裏我現在可以看到頂級catgories以下,但由於不能保存到錯誤
包含文件i_Alias.asp正在生成錯誤,並說:發生錯誤。目錄GID無效
這裏是包括文件代碼:i_Alias.asp
<%
Dim SQLCommand : SQLCommand = ""
Dim SQLFilter : SQLFilter = ""
Dim objConn : Set objConn = Server.CreateObject("ADODB.Connection")
Dim rsAlias : Set rsAlias = Server.CreateObject("ADODB.RecordSet")
Dim rsTemp : Set rsTemp = Server.CreateObject("ADODB.RecordSet")
Dim strUserError : strUserError = ""
Dim strFranchiseGID
Dim strDirectoryGID
Dim objEditor
Select Case Request.Form("Action")
Case "AddNew"
'strFranchiseGID = CleanSQLData(Request.Form("strFranchiseGID"))
'If strFranchiseGID = "" then strFranchiseGID = Null
strFranchiseGID = Session("AdminFranchiseGID")
strDirectoryGID = CleanSQLData(Request.Form("PGID"))
If strDirectoryGID = "" then
strUserError = strUserError & "An error has occured. The Directory GID is invalid"
end if
if strUserError = "" then
objConn.Open strConn
SQLCommand = "SELECT TOP 1 * FROM DirectoryAliases"
rsAlias.Open SQLCommand, objConn, adOpenKeySet, adLockOptimistic
rsAlias.AddNew
rsAlias("FranchiseGID") = strFranchiseGID
rsAlias("DirectoryGID") = strDirectoryGID
rsAlias.Update
rsAlias.Close
objConn.Close
'Response.Redirect "Default.asp?PGID=" & Request("PGID")
' Redirect to the New Parent Folders
Response.Redirect "Default.asp?PGID=" & strDirectoryGID
End if
Case "Update"
if Not Session("Role_Franchise_ManageDirectory") = True then
AccessDenied
End if
objConn.Open strConn
SQLCommand = "SELECT * FROM DirectoryAliases WHERE GID = '" & CleanSQLData(Request.Form("GID")) & "'"
rsAlias.Open SQLCommand, objConn, adOpenKeySet, adLockOptimistic
if rsAlias.RecordCount <> 1 then
FailSystemEvent "EditAlias Update failed - could not load unique record"
rsAlias.Close
objConn.Close
Response.End
End if
'strFranchiseGID = CleanSQLData(Request.Form("strFranchiseGID"))
'If strFranchiseGID = "" then strFranchiseGID = Null
strFranchiseGID = Session("AdminFranchiseGID")
rsAlias("FranchiseGID") = strFranchiseGID
strDirectoryGID = CleanSQLData(Request.Form("PGID"))
If strDirectoryGID = "" then
strUserError = strUserError & "An error occured. The Directory GID is invalid"
else
rsAlias("DirectoryGID") = strDirectoryGID
End if
rsAlias.Update
rsAlias.Close
objConn.Close
if strUserError = "" then
Response.Redirect "Default.asp?PGID=" & Request("PGID")
end if
Case "Delete"
if Not Session("Role_Franchise_ManageDirectory") = True then
AccessDenied
End if
SQLCommand = "DELETE DirectoryAliases WHERE GID = '" & CleanSQLText(Request.Form("GID")) & "'"
objConn.Open strConn
objConn.Execute SQLCommand
objConn.Close
End Select
%>
希望有人能幫助!
想必ParentDirectoryGID是空的頂級級別的ParentDirectories?你可以將它設置爲根GID嗎? – StevieG 2011-05-06 10:32:26