存储过程没有inparams和outparams

时间:2015-10-27 20:57:48

标签: mysql vb.net

我正在编写一个存储过程来调用数据库中的位置路径。如果我的存储过程中没有任何inparams和outparams怎么办?     代码就像:

CREATE DEFINER=`sqladmin`@`%` PROCEDURE `sp_getLocation`()

BEGIN

SELECT Lo.LocationPath

FROM Location Lo   

WHERE CategoryID=1;

END

如果我想在vb.net中调用此存储过程,我应该如何编写它来调用它。当我们拥有inparmas和outparams或其中任何一个时,我知道如何调用它。没有人熟悉他们。所以任何人都可以帮忙吗?

      Friend Function getLocationPath() As DataSet
    Try
        Dim dbh As New DatabaseHandler
        Dim ds As DataSet
        ds = dbh.callProcReturn("sp_getLocation", nothing, Nothing)


        Return ds

    Catch ex As Exception
        logException("getLocationpath", ex.Message)
        Throw
    End Try
End Function

调用procReturn方法的更新

 Friend Function callProcReturn(ByVal procName As String, ByVal inParams As Hashtable, ByRef outParams As Hashtable, _
                               Optional ByRef inoutParams As Hashtable = Nothing) As DataSet
    logQuery("callProcReturn", procName, inParams, inoutParams)
    Dim elapsedTicks As Long
    Dim elapsedSpan As New TimeSpan(elapsedTicks)
    elapsedTicks = Date.Now.Ticks
    Try
        Dim ds As New DataSet

        'Add the parameters if required
        '
        If inParams Is Nothing Then
            inParams = New Hashtable
        End If
        If Not inParams.Contains("P_UserId") Then
            inParams.Add("P_UserId", ConfigurationHandler.UserId)
        End If
        If Not inParams.Contains("P_MachineId") Then
            inParams.Add("P_MachineId", ConfigurationHandler.machineId)
        End If
        If Not inParams.Contains("P_ApplicationId") Then
            inParams.Add("P_ApplicationId", ConfigurationHandler.applicationId)
        End If

        'Do the actual query
        '
        Select Case UCase(_dbType)
            Case "MYSQL"
                ds = callSQLProcReturn(procName, inParams, outParams, inoutParams)
            Case "XML"
                ds = _xmlDatabase.callXMLProcReturn(procName, inParams, outParams, inoutParams)
            Case Else
                Throw New Exception("INVALID_DATABASE_TYPE")
        End Select

        Return ds

    Catch ex As Exception                                   
        logException("callProcReturn", ex.Message)
        Throw
    Finally
        logResult("callProcReturn", procName, outParams, inoutParams)
        elapsedSpan = New TimeSpan(Date.Now.Ticks - elapsedTicks)
        logVerbose("DatabaseHandler:callProcReturn[" & procName & "]-Elapsed: " & elapsedSpan.ToString)
    End Try
End Function

0 个答案:

没有答案