我没有任何编程经验VBScript
,我想使用一些OOP
方法。如果您在下面查看我的代码,您会看到我正在尝试使用一组返回数据集的方法创建 DB 访问类。不知道为什么,但收到错误:
Microsoft VBScript runtime error '800a01c2'
Wrong number of arguments or invalid property assignment
/TrashCan/library/BLL/CreditBLLClass.asp, line 18
我有一个.asp
页面:
<body>
<!-- #INCLUDE FILE="library\BLL\CreditBLLClass.asp" -->
<%
Dim creditBLL
Dim reader
creditBLL = new CreditBLLClass
reader = creditBLL.GetData()
If reader.EOF = False Then
Do While reader.EOF = False
Response.Write(reader.Fields("a").Value)
reader.MoveNext
Loop
End If
%>
</body>
CreditBLLClass.asp:
<!-- #INCLUDE FILE="DatabaseConnectionClass.asp" -->
<%
Class CreditBLLClass
'Private variables
Dim connection
Public Default Function Init()
Set Init = Me
End Function
Public Function GetData ()
connection = new DatabaseConnectionClass
GetData = connection.DBGetRecords("select a from b")
End Function
End Class
%>
和数据库连接类
<%
Class DatabaseConnectionClass
'Private variables
dim pConnection
Public Default Function Init()
Set Init = Me
End Function
Public Function DBGetRecords ( sSQL )
Set pConnection = Server.CreateObject( "ADODB.Connection" )
With pConnection
.ConnectionString = "string"
.Open
End With
DBGetRecords = pConnection.Execute ( sSQL )
End Function
End Class
%>
请告诉我我做错了什么?也许有一种常见的方法来构建数据访问层?