一個(gè)ACCESS數(shù)據(jù)庫(kù)訪問(wèn)的類(lèi)第3/3頁(yè)
更新時(shí)間:2006年07月09日 00:00:00 作者:
還有一個(gè)讀取XML的類(lèi) XmlReader:
<%
Class XmlReader Private Xml Public Sub Load(ByVal Path)
Xml.Load(Server.MapPath(Path))
End Sub Public Function SelectSingleNode(ByVal XPath)
Set SelectSingleNode = Xml.SelectSingleNode(XPath)
End Function Public Function SelectNodes(ByVal XPath)
Set SelectNodes = Xml.SelectNodes(XPath)
End Function
Private Sub Class_initialize()
Set Xml = Server.CreateObject("Microsoft.XMLDOM")
Xml.async = False
'Xml.setProperty "ServerHTTPRequest", True
End Sub
Private Sub Class_Terminate()
Set Xml = Nothing
End Sub End Class
%>
好了,萬(wàn)事俱備,開(kāi)始搭建基本的三層:
數(shù)據(jù)模型層:此層對(duì)應(yīng)成一個(gè)類(lèi),類(lèi)的類(lèi)名和字段屬性對(duì)應(yīng)于數(shù)據(jù)庫(kù)的相應(yīng)表名及字段。
考慮表News,其結(jié)構(gòu)如下:

則其對(duì)應(yīng)的模型層如下:
<%
Class DataNews Private IAddDate
Private IContent
Private ICount
Private INewsID
Private ITitle
Private IUserID
Private IUserName Public Property Let AddDate(ByVal Value)
IAddDate = Value
End Property
Public Property Get AddDate()
AddDate = IAddDate
End Property Public Property Let Content(ByVal Value)
IContent = Value
End Property
Public Property Get Content()
Content = IContent
End Property Public Property Let Count(ByVal Value)
ICount = Value
End Property
Public Property Get Count()
Count = ICount
End Property Public Property Let NewsID(ByVal Value)
INewsID = Value
End Property
Public Property Get NewsID()
NewsID = INewsID
End Property Public Property Let Title(ByVal Value)
ITitle = Value
End Property
Public Property Get Title()
Title = ITitle
End Property Public Property Let UserID(ByVal Value)
IUserID = Value
End Property
Public Property Get UserID()
UserID = IUserID
End Property Public Property Let UserName(ByVal Value)
IUserName = Value
End Property
Public Property Get UserName()
UserName = IUserName
End Property Private Sub Class_initialize()
End Sub
Private Sub Class_Terminate()
End Sub End Class
%>
這里用了類(lèi)名DataNews,因?yàn)閂BScript不支持Namespace(-_-),以前綴區(qū)分,而類(lèi)中私有屬性用I作前綴,沒(méi)什么特別含義,僅僅是因?yàn)镮所占寬度較小,不影響理解時(shí)的聯(lián)想反應(yīng)速度,如果非要拉點(diǎn)合理的解釋的話(huà),那么就是,Private中的I,以區(qū)分于Public,不用m_之類(lèi),是因?yàn)橛X(jué)得它不夠美觀,影響編碼心情(所以不喜歡寫(xiě)C),因?yàn)樾枰詢(xún)?yōu)雅之心情,編寫(xiě)優(yōu)雅的代碼(哎呀,誰(shuí)扔的雞蛋?拜托換個(gè)新鮮點(diǎn)的)。
相關(guān)文章
Access 2000 數(shù)據(jù)庫(kù) 80 萬(wàn)記錄通用快速分頁(yè)類(lèi)
Access 2000 數(shù)據(jù)庫(kù) 80 萬(wàn)記錄通用快速分頁(yè)類(lèi)...2007-03-03ASP中一個(gè)用VBScript寫(xiě)的隨機(jī)數(shù)類(lèi)
ASP中一個(gè)用VBScript寫(xiě)的隨機(jī)數(shù)類(lèi)...2006-08-08