如何獲取返回的memberID
變量插回到其他SQL存儲過程中?如何使我的應用程序中使用我的變量?
protected void imgBtnActivate_onClick(object sender, EventArgs e)
{
// Inserts Member record
try
{
Database db = DatabaseFactory.CreateDatabase(ConfigManager.AppSettings["ConnectionString.Dev"]);
DbCommand dbCommand = db.GetStoredProcCommand("dbo.ins_member_p");
db.AddInParameter(dbCommand, "@FirstName", DbType.String, txtFirstName.Text);
db.AddInParameter(dbCommand, "@LastName", DbType.String, txtLastName.Text);
db.ExecuteNonQuery(dbCommand);
int memberID = Convert.ToInt32(db.GetParameterValue(dbCommand, "MemberNewID").ToString());
}
catch (Exception ex)
{
ExceptionPolicy.HandleException(ex, "Notify Policy");
}
// Insert Member Email
try
{
Database db = DatabaseFactory.CreateDatabase(ConfigManager.AppSettings["ConnectionString.Dev"]);
DbCommand dbCommand = db.GetStoredProcCommand("[ins_MemberEmail_p]");
dbCommand.Transaction = dbTran;
db.AddInParameter(dbCommand, "MemberID", DbType.Int32, memberID);
db.AddInParameter(dbCommand, "SourceID", DBType.In32, 33);
db.AddInParameter(dbCommand, "EmailAddress", DbType.String, EncryptedEmailAddress);
}
catch (Exception ex)
{
ExceptionPolicy.HandleException(ex, "Notify Policy");
}
}