Solved

Printing parameter values from command object.  vb.net

Posted on 2007-04-10
4
230 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
  • 3
4 Comments
 
LVL 2

Expert Comment

by:soco180
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to shrink a transaction log file down to a reasonable size.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now