Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Printing parameter values from command object.  vb.net

Posted on 2007-04-10
4
Medium Priority
?
239 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Starting up a Project

688 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