1

私はプログラミングの経験がなく、何らかのアプローチ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

%>

私が間違っていることを教えてください。データアクセスレイヤーを構築する方法の一般的なアプローチはありますか?

4

1 に答える 1

4

エラーはエラーのinvalid property assignment部分にあります。

あなたのコードから:

connection = new DatabaseConnectionClass
GetData = connection.DBGetRecords("select a from b")

オブジェクトを使用するSetときに使用する必要があります。

これを次のように変更します。

Set connection = new DatabaseConnectionClass
Set GetData = connection.DBGetRecords("select a from b")
于 2012-04-19T19:37:21.587 に答える