Solved

Printing parameter values from command object.  vb.net

Posted on 2007-04-10
4
234 Views
Last Modified: 2010-04-14
Does anyone have some sample code for vb.net (web ap), where you can pass an sql server command object have it print each parameter.

ie. I want to pass my cmd object to a sub routine, and for each parameter response.write(parameter name + parameter value)

thanks
0
Comment
Question by:Fraser_Admin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 2

Expert Comment

by:soco180
ID: 18884924
Sorry this is in VB 6 (not .Net) but it should be similar.

Private Function ParamDump() As Long
On Error GoTo EH
Dim oParam As clsSpParam
Dim oCMD As ADODB.Command
Dim lParamCount As Long
    For Each oPrm In oCMD.Parameters
        Debug.Print oPrm.Name & " = '" & oPrm.Value & "'"
    Next
    ParamDump = lParamCount
End Function
0
 
LVL 2

Expert Comment

by:soco180
ID: 18884935
Oops, you wanted to pass the command object...

Private Function ParamDump(oCMD As ADODB.Command) As Long
On Error GoTo EH
Dim oParam As clsSpParam
Dim lParamCount As Long
    For Each oPrm In oCMD.Parameters
        Debug.Print oPrm.Name & " = '" & oPrm.Value & "'"
    Next
    ParamDump = lParamCount
End Function
0
 
LVL 2

Accepted Solution

by:
soco180 earned 500 total points
ID: 18884962
Sorry again. this is the last time (I hope)...I actually copied code from an app that I had previously wrote and deleted the other stuff. So I accidentally had a Class that I had built as a param wrapper, a class that you won't have.

Any here is my final VB 6 answer.

Private Function ParamDump(oCMD As ADODB.Command) As Long
On Error GoTo EH
Dim oPrm As ADODB.Parameter
Dim lParamCount As Long
    For Each oPrm In oCMD.Parameters
        Debug.Print oPrm.Name & " = '" & oPrm.Value & "'"
    Next
    ParamDump = lParamCount
End Function
0
 

Author Comment

by:Fraser_Admin
ID: 18890168
Thanks that was exactly what i wanted.  This is converted to .net

Friend Sub ParamDump(ByVal oCMD As SqlCommand)
        Dim oPrm As SqlParameter
        For Each oPrm In oCMD.Parameters
            HttpContext.Current.Response.Write(oPrm.ParameterName & " = " & oPrm.Value & "<BR>")
        Next
    End Sub
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question