Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Other Programming > BOOK: Professional Windows PowerShell Programming ISBN: 978-0-470-17393-0
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Professional Windows PowerShell Programming ISBN: 978-0-470-17393-0
This is the forum to discuss the Wrox book Professional Windows PowerShell Programming: Snapins, Cmdlets, Hosts and Providers by Arul Kumaravel, Jon White, Michael Naixin Li, Scott Happell, Guohui Xie, Krishna C. Vutukuri; ISBN: 9780470173930
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Windows PowerShell Programming ISBN: 978-0-470-17393-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 25th, 2011, 12:39 PM
Registered User
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Trying to execute a SQL stored procedure and it fails

I have written and tested a stored procedure in my ms sql database I am now trying to pass multiple parameters and run it. This one is just a simple insert procedure. I debug the powershell script and it opens the connection with the server but fails to pass the parameters. with the below error.

Exception calling "ExecuteNonQuery" with "0" argument(s): "Procedure or function 'sp_insertmds3re' expects parameter '@subid', which was not supplied

I do supply that paramter. here is the script below.

$sqlserver= "server"
$sqldatabase = "db"
$dbDefine="Server=$sqlserver;Database=$sqldatabase ;Uid=$UserName;Password=$Password;"
$DBConnection=New-Object System.Data.SqlClient.SqlConnection
$DBCommand=New-Object System.Data.SqlClient.SqlCommand
$DBCommand.Connection = $DBConnection
$DBCommand.commandtext = "[sp_insertmds3re]"
$DBCommand.CommandType = [System.Data.CommandType]::StoredProcedure

$DBCommand.Parameters.Add("`'1`'",[system.Data.SqlDbType]::Int) | Out-Null
$DBCommand.Parameters.Add("`'5/1/2010 12:00:00 AM`'",[System.Data.SqlDbType]::SmallDateTime) |Out-Null
$DBCommand.Parameters.Add("`'Name`'",[system.Data.SqlDbType]::VarChar,20)| Out-Null
$DBCommand.Parameters.Add("`'1`'",[system.Data.SqlDbType]::SmallInt) | Out-Null
$DBCommand.Parameters.Add("`'2`'",[system.Data.SqlDbType]::SmallInt)| Out-Null
$DBCommand.Parameters.Add("`'3`'",[system.Data.SqlDbType]::SmallInt)| Out-Null
$DBCommand.Parameters.Add("`'Completed`'",[system.Data.SqlDbType]::VarChar,20)| Out-Null


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't See SQL tables and Stored Procedure azambee SQL Server 2000 1 October 24th, 2008 01:03 PM
Execute Stored Procedure from VBA Romashka Access VBA 1 February 22nd, 2007 12:52 PM
SQL Server Stored Procedure doug SQL Server 2000 2 February 22nd, 2005 03:04 PM
dymanic sql vs stored procedure prox_lae Oracle 0 February 19th, 2004 10:30 PM
SQL Stored Procedure... babloo81 SQL Server ASP 1 December 8th, 2003 03:38 PM

All times are GMT -4. The time now is 09:45 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.