Click here to Skip to main content
15,391,382 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[^]
   
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.
Member 9017207 21-Aug-15 1:56am
   
in the solution explorer I don't fine anything. Can you please help?
D V L 21-Aug-15 1:59am
   
http://www.c-sharpcorner.com/UploadFile/84c85b/using-ado-net-entity-framework-5-0/Images/Solution%20Explorer%20displaying%20the%20generated%20Entity%20Data%20Model.jpg
Member 9017207 21-Aug-15 2:00am
   
In the solution explorer I have the following folders

Project1
Project1.BusinessEntities
Project1.BusinessLogic
Project1.DataAccess
Project1.LINQObjects
D V L 21-Aug-15 2:03am
   
expand all project in solution and see where is it..
Member 9017207 21-Aug-15 2:06am
   
Didn't find the edmx file in any of the folders. I have the class diagrams file though. The .cd files
D V L 21-Aug-15 2:05am
   
to find your edmx file use search bar of solution explorer
or use shortcut ctrl + ;
and type edmx
Member 9017207 21-Aug-15 2:07am
   
Did that. Didn't find the edmx file
D V L 21-Aug-15 2:12am
   
may be you have code first approach of entity framework.

in that case you can add parameter manually to your stored procedure function and map.
Member 9017207 21-Aug-15 2:17am
   
I have already added parameters manually to the stored procedure. But still same error
D V L 21-Aug-15 2:18am
   
try following link it could help

http://www.entityframeworktutorial.net/EntityFramework6/code-first-insert-update-delete-stored-procedure-mapping.aspx
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.
   
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