Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi. My problem is I want to add another field for insert i.e ImagePath.
But when I try to add the logic for Insert ImagePath in business logic it shows No overload for 'SP_INSERT_INTO_FONDATION_BOLT_MST' method takes 21 arguments.

'SP_INSERT_INTO_FONDATION_BOLT_MST' is the stored procedure used for insert.

Below is the business logic
C#
public class FoundationBoltLogic
    {
        protected MastersDataContext context = new MastersDataContext();

        public string InsertData(FoundationBoltEntities BoltEntity)
        {

            ISingleResult<SP_INSERT_INTO_FONDATION_BOLT_MSTResult> ds = context.SP_INSERT_INTO_FONDATION_BOLT_MST(BoltEntity.JBoltNos, BoltEntity.JBoltNos_desc, BoltEntity.JBoltDia, BoltEntity.JBoltDia_desc, BoltEntity.YieldStress, BoltEntity.YieldStress_desc, BoltEntity.PitchCircleDia, BoltEntity.PitchCircleDia_desc, BoltEntity.BoltLen, BoltEntity.BoltLen_desc, BoltEntity.ProjectedBLen, BoltEntity.ProjectedBLen_desc, BoltEntity.Cost, BoltEntity.Product_Type, BoltEntity.Bolt_Type, BoltEntity.ED_ACC, BoltEntity.UNIT_OF_MEASUREMENT, BoltEntity.IsActive, BoltEntity.CreatedBy, BoltEntity.CreatedOn, BoltEntity.ImagePath);

            string strResult = "ERROR";

            foreach (SP_INSERT_INTO_FONDATION_BOLT_MSTResult row in ds)
            {
                strResult = row.STATUS;
                if (strResult == "ERROR")
                {
                    strResult = row.ERROR_MESSAGE;
                }

            }

            return strResult;
        }


Please suggest what can I do to insert another field. I have created ImagePath field in the table. And also added in stored procedure.
Posted

try this

1. Open your .edmx file.
2. In the Model Browser, right-click the .edmx file and select "Update Model from Database".
3. Click the Refresh tab.
4. Click Finish button to update the .edmx file with the database changes.


for advance follow the link

https://msdn.microsoft.com/en-us/library/vstudio/cc716697%28v=vs.100%29.aspx[^]
 
Share this answer
 
Comments
Member 9017207 21-Aug-15 1:44am    
Where to find the .edmx file? And the model browser?
D V L 21-Aug-15 1:48am    
in your solution explorer
D V L 21-Aug-15 1:48am    
are you using Entity Framework?
specify what are u using?
Member 9017207 21-Aug-15 1:53am    
yes i am using entity framework
D V L 21-Aug-15 1:57am    
then find your .edmx file in solution explorer
double click or open it
it show diagram view of your models.
The error message is quite clear, you're trying to provide different amount of parameters to the stored procedure than what it expects. You now use 21 parameters but the stored procedure expects perhaps 20 or 22 or something like that.

Without seeing the definition of the procedure, it's impossible to say where the mismatch is but double check the parameters you use compared to the stored procedure definition. If the stored procedure has been changed, verify that you have refreshed your data model to correspond with latest changes.
 
Share this answer
 
v2
Comments
Member 9017207 21-Aug-15 1:28am    
Stored procedure have been changed. But how to refresh the data model? Sorry I"m a newbie. Can you please tell me the procedure?

Here is the whole procedure.

ALTER PROCEDURE [dbo].[SP_INSERT_INTO_FONDATION_BOLT_MST]

@JBoltNos BIGINT ,
@JBoltNos_desc [varchar](50),/*Added by Avinaash on 05/06/2013 */
@JBoltDia BIGINT ,
@JBoltDia_desc [varchar](50),/*Added by Avinaash on 05/06/2013 */
@YieldStress BIGINT ,
@YieldStress_desc [varchar](50),/*Added by Avinaash on 05/06/2013 */
@PitchCircleDia BIGINT ,
@PitchCircleDia_desc [varchar](50),/*Added by Avinaash on 05/06/2013 */
@BoltLen BIGINT ,
@BoltLen_desc [varchar](50),/*Added by Avinaash on 05/06/2013 */
@ProjectedBLen BIGINT ,
@ProjectedBLen_desc [varchar](50),/*Added by Avinaash on 05/06/2013 */
@Cost INT ,
@Product_Type [bigint],/*Added by Avinaash on 05/06/2013 */
@Bolt_Type [varchar](30),/*Added by Avinaash on 05/06/2013 */
@ED_ACC [bit],/*Added by Avinaash on 05/06/2013 */
@UNIT_OF_MEASUREMENT [varchar](50),/*Added by Avinaash on 05/06/2013 */
@IsActive BIT ,
@CreatedBy BIGINT ,
@CreatedOn DATETIME,
@ImagePath VARCHAR(MAX)

AS
BEGIN
SET NOCOUNT ON;
BEGIN TRY

BEGIN --condiditon to check 'similar data present' added by prasadh july 8rd 2013
IF exists( Select 'x' From DEF_FONDATION_BOLT_MST where [JBoltNos]=@JBoltNos AND [JBoltDia]=@JBoltDia AND [BoltLen]=@BoltLen AND [Product_Type]=@Product_Type and [Bolt_Type]=@Bolt_Type )
BEGIN
RAISERROR('Record With Similar Bolt Number,Diameter,Length For Associated Product & Bolt Type Already Present',16,1)
END

ELSE

BEGIN
--BEGIN TRANSACTION TransInsertBOLT
INSERT INTO dbo.DEF_FONDATION_BOLT_MST (/*Insertion Begins*/
[JBoltNos]
,[JBoltNos_desc]/*Added by Avinaash on 05/06/2013*/
,[JBoltDia]
,[JBoltDia_desc]
,[YieldStress]
,[YieldStress_desc]
,[PitchCircleDia]
,[PitchCircleDia_desc]
,[BoltLen]
,[BoltLen_desc]
,[ProjectedBLen]
,[ProjectedBLen_desc]
,[Cost]
,[Product_Type]
,[Bolt_Type]
,[ED_ACC]
,[UNIT_OF_MEASUREMENT]
,[IsActive]
,[CreatedBy]
,[CreatedOn]
,[ImagePath]
) VALUES(
@JBoltNos
,@JBoltNos_desc
,@JBoltDia
,@JBoltDia_desc
,@YieldStress
,@YieldStress_desc
,@PitchCircleDia
,@PitchCircleDia_desc
,@BoltLen
,@BoltLen_desc
,@ProjectedBLen
,@ProjectedBLen_desc
,@Cost
,@Product_Type
,@Bolt_Type
,@ED_ACC
,@UNIT_OF_MEASUREMENT
,@IsActive
,@CreatedBy
,@CreatedOn
,@ImagePath
)
/*Returns Success*/
SELECT 'SUCCESS' AS [STATUS],ERROR_LINE() [ERROR_LINE],ERROR_MESSAGE() [ERROR_MESSAGE],ERROR_NUMBER() [ERROR_NUMBER],ERROR_PROCEDURE() [ERROR_PROCEDURE],ERROR_SEVERITY() [ERROR_SEVERITY],ERROR_STATE() [ERROR_STATE],@@TRANCOUNT [TRANCOUNT],@@ROWCOUNT [ROWCOUNT]
--COMMIT TRANSACTION TransInsertBOLT
END
END

END TRY
BEGIN CATCH
--ROLLBACK TRANSACTION TransInsertBOLT
/*Returns Error*/
SELECT 'ERROR' AS [STATUS],ERROR_LINE() [ERROR_LINE],ERROR_MESSAGE() [ERROR_MESSAGE],ERROR_NUMBER() [ERROR_NUMBER],ERROR_PROCEDURE() [ERROR_PROCEDURE],ERROR_SEVERITY() [ERROR_SEVERITY],ERROR_STATE() [ERROR_STATE],@@TRANCOUNT [TRANCOUNT],@@ROWCOUNT [ROWCOUNT]
END CATCH
SET NOCOUNT OFF;
END
Wendelius 21-Aug-15 2:39am    
Or if you use code first, then apply update-database, see https://msdn.microsoft.com/en-us/data/jj591621.aspx[^]

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