Click here to Skip to main content
15,886,763 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public int CompanyRegister(CompanyRegistration Cr, out int CompanyID)
{
//int NewCompanyID = 0;
DataTable dt = new DataTable();
try
{

SqlParameter NewCompanyID = new SqlParameter("@CompID", SqlDbType.Int);
NewCompanyID.Direction = ParameterDirection.Output;
//NewCompanyID = Convert.ToInt32(OutNonloanChargeBalance.Value);

SqlParameter[] param ={
new SqlParameter(@CompName,Cr.CompanyName),
new SqlParameter(@LogoPath,Cr.companylog),
new SqlParameter(@TypeofBusiness,Cr.Typeofbusiness),


dt = sh.ExecuteDataTable("dbo.Insert_ALOrganization", param);

CompanyID = Convert.ToInt32(NewCompanyID.Value);

}
catch (Exception ex)
{
throw ex;
}
return CompanyID;
}
}



here i willpass allthese value and i will get oup put in the varibla ie:CompanyID
Posted

1 solution

You are not including your NewCompanyID parameter in SqlParameter array param.
C#
public int CompanyRegister(CompanyRegistration Cr)
{
int CompanyID=0; 
DataTable dt = new DataTable();
try
{
SqlParameter NewCompanyID = new SqlParameter("@CompID", SqlDbType.Int);
NewCompanyID.Direction = ParameterDirection.Output; 
SqlParameter[] param = { NewCompanyID ,
new SqlParameter(@CompName,Cr.CompanyName),
new SqlParameter(@LogoPath,Cr.companylog),
new SqlParameter(@TypeofBusiness,Cr.Typeofbusiness)
}
dt = sh.ExecuteDataTable("dbo.Insert_ALOrganization", param);
CompanyID = Convert.ToInt32(NewCompanyID.Value);
}
catch (Exception ex)
{
throw ex;
}
return CompanyID;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900