1

How would I add parameters to this stored procedure? And am I doing anything else wrong? I've already established my connection to server/db. I've searched, but keep getting conflicting answers. Any help would be appreciated!!

$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = "sp_name_here"
$SqlCmd.Connection = $srcCnn

$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)

$DataSet.Tables[0]

1 Answer 1

2

You should be able to simply call the Add method on the command object's Parameters property.

$Param = $SqlCmd.Parameters.Add("@paramName", [Data.SqlDbType]::VarChar)
$Param.Direction = [Data.ParameterDirection]::Input
$Param.Value = "SomeValueHere"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.