Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8586651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:21:39+00:00 2026-06-11T22:21:39+00:00

When i Fill all the data in the web form the below Stored procedure

  • 0

When i Fill all the data in the web form the below Stored procedure working fine but if I leave some columns like AwardName2,Authority2,AwardYear2 and Remarks2 (I mention this columns as NULL in my table), the program throw the Error “Failed to convert parameter value from a string to a Int 32” . What changes i have to do in the Stored procedure ? please help.

    ALTER PROCEDURE [dbo].[usp_RegPage2]  
     @Vendor_ID VARCHAR(16), @EmpDetailsDocPath VARCHAR(200), @EmpTotalNo INT,
     @EmpAbove5Years INT, @EmpEnggDesign INT, @EmpProContract INT, @QADocPath VARCHAR(200), 
     @QAStandard VARCHAR(50), @QADocument CHAR(3), @QAControl CHAR(3), @HSEDocPath VARCHAR(200),
     @HSEStandard VARCHAR(15), @HSEDocument CHAR(3), @HSEControlManual CHAR(3),
     @AuthorityDocPath VARCHAR(200), @AwardName1 VARCHAR(50), @Authority1 VARCHAR(50),  
     @AwardYear1 INT,@Remarks1 VARCHAR(70),@AwardName2 VARCHAR(50),
     @Authority2 VARCHAR(50), @AwardYear2 INT, @Remarks2 VARCHAR(70), @AwardName3 VARCHAR(50), 
     @Authority3 VARCHAR(50), @AwardYear3 INT, @Remarks3 VARCHAR(70),
     @AwardName4 VARCHAR(50), @Authority4 VARCHAR(50), @AwardYear4 INT, @Remarks4 VARCHAR(70),
     @BritishStandard CHAR(3), @AmericanStandard CHAR(3), @OtherStandard VARCHAR(50),      
     @REManpower CHAR(3), @RESubContract CHAR(3), @RELabourPath VARCHAR(200),
     @REEquipmentPath VARCHAR(200), @REShop CHAR(3), @REAssemblyyard CHAR(3), 
     @RESizeofShop INT,@REHouse CHAR(3),@REOutSource CHAR(3),@ProjectDocPath VARCHAR(200),      
     @CmpVision VARCHAR(200), @CmpFullRegDate DATE = NULL
     AS   SET @CmpFullRegDate  = COALESCE(@CmpFullRegDate,GETDATE());
     BEGIN   
   INSERT INTO dbo.RegPage2     
   (Vendor_ID,EmpDetailsDocPath,EmpTotalNo,EmpAbove5Years,EmpEnggDesign,EmpProContract,
    QADocPath,QAStandard,QADocument,QAControl,HSEDocPath,HSEStandard,HSEDocument,
    HSEControlManual,AuthorityDocPath,AwardName1,Authority1,AwardYear1,Remarks1,
    AwardName2,Authority2,AwardYear2,Remarks2,AwardName3,Authority3,AwardYear3,Remarks3,
    AwardName4,Authority4,AwardYear4,Remarks4,BritishStandard,AmericanStandard,      
    OtherStandard,REManpower,RESubContract,RELabourPath,REEquipmentPath,REShop,
    REAssemblyyard,RESizeofShop,REHouse,REOutSource,ProjectDocPath,CmpVision,CmpFullRegDate) 
    VALUES       
    (@Vendor_ID,@EmpDetailsDocPath,@EmpTotalNo,@EmpAbove5Years,@EmpEnggDesign,@EmpProContract,
     @QADocPath,@QAStandard,@QADocument,@QAControl,@HSEDocPath,@HSEStandard,@HSEDocument,
   @HSEControlManual,@AuthorityDocPath,@AwardName1,@Authority1,@AwardYear1,@Remarks1,@AwardName2,
   @Authority2,@AwardYear2,@Remarks2,@AwardName3,@Authority3,@AwardYear3,@Remarks3,
   @AwardName4,@Authority4,@AwardYear4,@Remarks4,@BritishStandard,@AmericanStandard,   
   @OtherStandard,@REManpower,@RESubContract,@RELabourPath,@REEquipmentPath,@REShop,
   @REAssemblyyard,@RESizeofShop,@REHouse,@REOutSource,@ProjectDocPath,
   @CmpVision,@CmpFullRegDate)    
   END

C# Code

      protected void BtnRegPage2Save_Click(object sender, EventArgs e)
      {
      SqlConnection SqlCon = new SqlConnection(GetConnectionString());
      SqlCommand cmd = new SqlCommand();
      cmd.CommandType = CommandType.StoredProcedure;
      cmd.CommandText = "usp_RegPage2";
      cmd.Parameters.Add("@Vendor_ID", SqlDbType.VarChar).Value = lblPage2ID.Text;
      cmd.Parameters.Add("@EmpDetailsDocPath", SqlDbType.VarChar).Value = AFU7.FileName;
      cmd.Parameters.Add("@EmpTotalNo", SqlDbType.Int).Value = txtTotalEmp.Text.Trim();
      cmd.Parameters.Add("@EmpAbove5Years", SqlDbType.Int).Value = txtstability.Text.Trim();
      cmd.Parameters.Add("@EmpEnggDesign", SqlDbType.Int).Value = txtEnggDesign.Text.Trim();
      cmd.Parameters.Add("@EmpProContract", SqlDbType.Int).Value = txtProContract.Text.Trim();
      cmd.Parameters.Add("@QADocPath", SqlDbType.VarChar).Value = AFU8.FileName;
      cmd.Parameters.Add("@QAStandard", SqlDbType.VarChar).Value = ddlQACertificate.Text.Trim();
      cmd.Parameters.Add("@QADocument", SqlDbType.Char).Value = ddlQSDocument.Text.Trim();
      cmd.Parameters.Add("@QAControl", SqlDbType.Char).Value = ddlQCManual.Text.Trim();
      cmd.Parameters.Add("@HSEStandard", SqlDbType.VarChar).Value = ddlHSECertificate.Text;
      cmd.Parameters.Add("@HSEDocument", SqlDbType.Char).Value = ddlHSEDocument.Text;
      cmd.Parameters.Add("@HSEControlManual", SqlDbType.Char).Value = ddlHSEManual.Text;
      cmd.Parameters.Add("@HSEDocPath", SqlDbType.VarChar).Value = AFU9.FileName;
      cmd.Parameters.Add("@AuthorityDocPath", SqlDbType.VarChar).Value = AFU3.FileName;
      cmd.Parameters.Add("@AwardName1", SqlDbType.VarChar).Value = txtAward1.Text.Trim();
      cmd.Parameters.Add("@Authority1", SqlDbType.VarChar).Value = txtAuthority1.Text.Trim();
      cmd.Parameters.Add("@AwardYear1", SqlDbType.Int).Value = txtYear1.Text.Trim();
      cmd.Parameters.Add("@Remarks1", SqlDbType.VarChar).Value = txtRemarks1.Text.Trim();
      cmd.Parameters.Add("@AwardName2", SqlDbType.VarChar).Value = txtAward2.Text.Trim();
      cmd.Parameters.Add("@Authority2", SqlDbType.VarChar).Value = txtAuthority2.Text.Trim();
      cmd.Parameters.Add("@AwardYear2", SqlDbType.Int).Value = txtYear2.Text.Trim();
      cmd.Parameters.Add("@Remarks2", SqlDbType.VarChar).Value = txtRemarks2.Text.Trim();
      cmd.Parameters.Add("@AwardName3", SqlDbType.VarChar).Value = txtAward3.Text.Trim();
      cmd.Parameters.Add("@Authority3", SqlDbType.VarChar).Value = txtAuthority3.Text.Trim();
      cmd.Parameters.Add("@AwardYear3", SqlDbType.Int).Value = txtYear3.Text.Trim();
      cmd.Parameters.Add("@Remarks3", SqlDbType.VarChar).Value = txtRemarks3.Text.Trim();
      cmd.Parameters.Add("@AwardName4", SqlDbType.VarChar).Value = txtAward4.Text.Trim();
      cmd.Parameters.Add("@Authority4", SqlDbType.VarChar).Value = txtAuthority4.Text.Trim();
      cmd.Parameters.Add("@AwardYear4", SqlDbType.Int).Value = txtYear4.Text.Trim();
      cmd.Parameters.Add("@Remarks4", SqlDbType.VarChar).Value = txtRemarks4.Text.Trim();
      cmd.Parameters.Add("@BritishStandard", SqlDbType.Char).Value = ddlBritishStd.Text.Trim();
      cmd.Parameters.Add("@AmericanStandard", SqlDbType.Char).Value = ddlAmericanStd.Text.Trim();
      cmd.Parameters.Add("@OtherStandard", SqlDbType.VarChar).Value = txtOthers.Text.Trim();
      cmd.Parameters.Add("@REManpower", SqlDbType.Char).Value = ddlOwnManpower.Text.Trim();
      cmd.Parameters.Add("@RESubContract", SqlDbType.Char).Value = ddlSubContract.Text.Trim();
      cmd.Parameters.Add("@RELabourPath", SqlDbType.VarChar).Value = AFU4.FileName;
      cmd.Parameters.Add("@REEquipmentPath", SqlDbType.Char).Value = AFU5.FileName;
      cmd.Parameters.Add("@REShop", SqlDbType.Char).Value = ddlAtShop.Text;
      cmd.Parameters.Add("@REAssemblyyard", SqlDbType.Char).Value = ddlAssembly.Text;
      cmd.Parameters.Add("@RESizeofShop", SqlDbType.Int).Value = txtAssemblysize.Text;
      cmd.Parameters.Add("@REHouse", SqlDbType.Char).Value = ddlInHouse.Text;
      cmd.Parameters.Add("@REOutSource", SqlDbType.Char).Value = ddlOutSourcing.Text;
      cmd.Parameters.Add("@ProjectDocPath", SqlDbType.VarChar).Value = AFU6.FileName;
      cmd.Parameters.Add("@CmpVision", SqlDbType.VarChar).Value = txtVision.Text.Trim();
      cmd.Connection = SqlCon;
      try
      {
         SqlCon.Open();
         cmd.ExecuteNonQuery();
      }
      catch (Exception ex)
      {
         throw new Exception(ex.Message);
      }
      finally
      {
         SqlCon.Close();
         SqlCon.Dispose();
      }
     }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:21:40+00:00Added an answer on June 11, 2026 at 10:21 pm

    Making your columns NULL in the table does not mean your PROC would automatically assign null to the parameter that corresponds to that column

    The culprit is probably @AwardYear and other int parameters. You need to pass DBNull from your code

    if(String.IsNullOrEmpty(AwardYear))
       command.Parameters.AddWithValue("@AwardYear", DBNull.Value);
    else
       command.Parameters.AddWithValue("@AwardYear", Convert.ToInt32(AwardYear));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some of my columns need explicit widths, while others should just fill up all
Afternoon All, I have a web form that i wish my user to fill
Okay all, I have a form that I want users to fill out. When
I'm working on some web app and on one of my content pages I
I m working with some web services where i m requesting for web service
Our DBA requires us to return all tabular data from stored procedures in a
I'm using HtmlUnit to programatically fill out and submit a web form in Java.
I'm working on a web site with joomla 1.5, so to import the data
I want to fill all cells with the same control. What I have now
I use the following code to fill all empty keys in sub-arrays with ``

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.