S
Stephen Lynch
I am running a stored procedure via code but need help with the sytax for
the output parameter:
When I run this it works in SQL:
USE DataInput
GO
DECLARE @MyIdent int
EXEC a_spAppendNewContributionID
@CompanyId=1000,
@PayPeriod="8/12/2006",
@PlanYear=2006,
@ContributionDate="08/25/2006",
@ContributionID = @MyIdent OUTPUT
SELECT @MyIdent AS IdentityValue
SELECT * FROM MassPost
Here's part of my code. The @contributionID section is where I am
stuck, how do I declare the output parameter?
// Add Parameters to SPROC
OleDbParameter parameterCompanyId = new
OleDbParameter("@CompanyId", OleDbType.Integer, 4);
parameterCompanyId.Value = SystemUtils.GetUserID();
myCommand.Parameters.Add(parameterCompanyId);
OleDbParameter parameterPayPeriod = new
OleDbParameter("@PayPeriod", OleDbType.Date, 8);
parameterPayPeriod.Value = this.PayPeriod2.Text;
myCommand.Parameters.Add(parameterPayPeriod);
OleDbParameter parameterPlanYear = new
OleDbParameter("@PlanYear", OleDbType.Integer, 4);
parameterPlanYear.Value = this.PlanYear2.Text;
myCommand.Parameters.Add(parameterPlanYear);
OleDbParameter parameterContributionDate = new
OleDbParameter("@ContributionDate", OleDbType.Date, 8);
parameterContributionDate.Value =
this.ContributionDate2.Text;
myCommand.Parameters.Add(parameterContributionDate);
//Line that does not work
OleDbParameter parameterContributionID = new
OleDbParameter("@ContributionID", OleDbType.Integer, 4);
parameterContributionID.Direction =
ParameterDirection.Output
Thanks
the output parameter:
When I run this it works in SQL:
USE DataInput
GO
DECLARE @MyIdent int
EXEC a_spAppendNewContributionID
@CompanyId=1000,
@PayPeriod="8/12/2006",
@PlanYear=2006,
@ContributionDate="08/25/2006",
@ContributionID = @MyIdent OUTPUT
SELECT @MyIdent AS IdentityValue
SELECT * FROM MassPost
Here's part of my code. The @contributionID section is where I am
stuck, how do I declare the output parameter?
// Add Parameters to SPROC
OleDbParameter parameterCompanyId = new
OleDbParameter("@CompanyId", OleDbType.Integer, 4);
parameterCompanyId.Value = SystemUtils.GetUserID();
myCommand.Parameters.Add(parameterCompanyId);
OleDbParameter parameterPayPeriod = new
OleDbParameter("@PayPeriod", OleDbType.Date, 8);
parameterPayPeriod.Value = this.PayPeriod2.Text;
myCommand.Parameters.Add(parameterPayPeriod);
OleDbParameter parameterPlanYear = new
OleDbParameter("@PlanYear", OleDbType.Integer, 4);
parameterPlanYear.Value = this.PlanYear2.Text;
myCommand.Parameters.Add(parameterPlanYear);
OleDbParameter parameterContributionDate = new
OleDbParameter("@ContributionDate", OleDbType.Date, 8);
parameterContributionDate.Value =
this.ContributionDate2.Text;
myCommand.Parameters.Add(parameterContributionDate);
//Line that does not work
OleDbParameter parameterContributionID = new
OleDbParameter("@ContributionID", OleDbType.Integer, 4);
parameterContributionID.Direction =
ParameterDirection.Output
Thanks