VB.Net循环遍历SQL命令和日志名称+值中的每个参数

时间:2015-10-15 14:19:23

标签: vb.net logging sqlcommand

我可以遍历SQL Command中的每个参数但是如何记录 parametername和Value?

Public  Sub LogParams(sqlcmd As SqlCommand)
        Dim strParam As String = ""
        For Each p As SqlParameter In sqlcmd.Parameters
             strParam +=      'how to get Name and Value of parameter?
        Next p
End Sub

1 个答案:

答案 0 :(得分:2)

您可以将其用作

For Each p As SqlParameter In sqlcmd.Parameters
    'p.ParameterName
    'p.Vaalue
Next p