如何通过vb.net使用业务连接器从AX读取数据?

时间:2018-08-31 06:41:03

标签: vb.net visual-studio-2008 axapta dynamics-ax-2009

我为斧头添加了参考,但我不知道如何连接AX以通过vb.net代码读取数据,

有人可以建议我为此取样吗?

预先感谢

2 个答案:

答案 0 :(得分:1)

您需要进入AxaptaRecord类,并在其上调用.next()以通读结果。

这里有一些c#示例代码,您应该可以将它们转换为VB .NET:How to: Read Data Using .NET Business Connector

答案 1 :(得分:0)

使用这种方法在vb中调用ax;

部分公共类ValueReport

<DataMethod(), AxSessionPermission(SecurityAction.Assert)> Public Shared Function CompanyInfo() As DataTable
    Dim dtCompany As New DataTable
    Try
        Dim record As AxaptaRecordWrapper = SessionManager.GetSession().CreateAxaptaRecord("CompanyInfo")
        record.ExecuteStmt("select * from %1")

        dtCompany.Columns.Add("CompanyName", System.Type.GetType("System.String"))
        dtCompany.Columns.Add("CompanyAddress", System.Type.GetType("System.String"))

        While (record.Found)
            Dim drCompany As DataRow = dtCompany.NewRow
            drCompany("CompanyName") = record.GetField("Name")
            drCompany("CompanyAddress") = record.GetField("Address")
            dtCompany.Rows.Add(drCompany)
            record.Next()
        End While

        Return dtCompany

    Catch ex As Exception
        Throw ex
    End Try

End Function