0

我试图弄清楚如何从我的 Silverlight 应用程序中调用存储过程。我可以使用这个函数调用数据库:

<OperationContract()>
Public Function ImportData(
    ByVal authentication As AuthenticationArgs,
    ByVal caseID As String) As ResponseArgs(Of GetGuidelineData_Result)

    Dim guidelineDataResults As GetGuidelineData_Result
    Dim exception As ExceptionArgs = Nothing

    If AuthenticationService.CheckPermissions(authentication, exception, PermissionType.StateUser) Then

        Try
            Dim model As DCF_ACCESS_Model = DataHelper.CreateDCF_ACCESS_Model()

            model.GetGuidelineData(caseID)

        Catch ex As Exception

            Return New ResponseArgs(Of GetGuidelineData_Result)(New ExceptionArgs(ex.Message))

        End Try

        Return New ResponseArgs(Of GetGuidelineData_Result)(guidelineDataResults)

    Else

        Return New ResponseArgs(Of GetGuidelineData_Result)(exception)

    End If

End Function

我怎样才能修改代码来调用存储过程呢?存储过程 GetGuidelineData 将 1 个参数作为输入。

4

1 回答 1

0

我能够弄清楚如何使用以下方法调用存储过程:

<OperationContract()>
Public Function ImportData(
    ByVal authentication As AuthenticationArgs,
    ByVal caseID As String) As ResponseArgs(Of GetGuidelineData_Result)

    Dim guidelineDataResults As GetGuidelineData_Result
    Dim exception As ExceptionArgs = Nothing

    If AuthenticationService.CheckPermissions(authentication, exception, PermissionType.StateUser) Then

        Try
            Dim model As DCF_ACCESS_Model = DataHelper.CreateDCF_ACCESS_Model()

            ' Call stored procedure
            guidelineDataResults = model.GetGuidelineData(caseID).First()

        Catch ex As Exception

            Return New ResponseArgs(Of GetGuidelineData_Result)(New ExceptionArgs(ex.ToString()))

        End Try

        Return New ResponseArgs(Of GetGuidelineData_Result)(guidelineDataResults)

    Else

        Return New ResponseArgs(Of GetGuidelineData_Result)(exception)

    End If


End Function

对存储过程的调用通过以下方式完成:

 model.GetGuidelineData(caseID).First()

它获取集合中的第一个元素并将其作为输出返回。

于 2013-04-17T21:06:30.873 回答