Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you see the name and value of a parameter? 1

Status
Not open for further replies.

emaduddeen

Programmer
Mar 22, 2007
184
US
Hi Everyone,

If I use the following code to create a parameter can you tell me how to extract the parameter name and the parameter value?

Code:
objSqlCommand.Parameters.AddWithValue("@MyParam", "CA").DbType = DbType.String

Truly,
Emad
 
Is this what you are looking for?

Code:
            objSqlCommand.Parameters("@MyParam").Value
            objSqlCommand.Parameters("@MyParam").ParameterName
 
Hi RiverGuy,

Yes that's what I needed.

Thanks so much.

Here's you code I used:

Code:
            ' Write out command parameters and values.
            '-----------------------------------------
            txtResults.Text = txtResults.Text & "Command parameters:" & vbCrLf

            For Each objSqlParameter In .Parameters
                txtResults.Text = txtResults.Text & ControlChars.Tab & _
                objSqlCommand.Parameters("@MyParam").ParameterName & "=" & _
                objSqlCommand.Parameters("@MyParam").Value.ToString & vbCrLf
            Next

Truly,
Emad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top