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

  • SEARCH
  • Home
  • 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 7705769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:56:38+00:00 2026-05-31T23:56:38+00:00

I have a stored procedure that has been working just fine, but I recently

  • 0

I have a stored procedure that has been working just fine, but I recently added three new params to it:

**@HasObits**, **@AlternateName**, and **@Notes**.

CREATE PROCEDURE dbo.sp_InsertNewRecord 
(
@CountryID int, 
@StateID int, 
@CountyID int, 
@RecordsOnline bit = 0, 
**@HasObits bit = 0,**
@Name varchar(100), 
**@AlternateName varchar(100) = null,**
@Address varchar(50) = null,
@Address2 varchar(50) = null,
@City varchar(50) = null,
@ZipCode varchar(10) = null,
@Phone char(10) = null,
@Fax char(10) = null,
@Email varchar(50) = null,
@Website varchar(100) = null,
@SearchURI varchar(150) = null, 
**@Notes text = null,** 
@AddedBy uniqueidentifier = null
)

AS 

BEGIN 
    SET NOCOUNT ON 

INSERT INTO MyTable (CountryID, StateID, CountyID, RecordsOnline, HasObituaries, [Name], AlternateName, [Address], Address2, City, ZipCode, Phone, Fax, Email, Website, SearchURI, Notes, AddedBy)
    VALUES (@CountryID, @StateID, @CountyID, @RecordsOnline, @HasObits, @Name, @AlternateName, @Address, @Address2, @City, @ZipCode, @Phone, @Fax, @Email, @Website, @SearchURI, @Notes, @AddedBy)

END
GO

This code is being called by my data access layer in this method:

public void Insert(Company company)
    {
        // create connection
        SqlConnection conn = new SqlConnection(_connectionString);

        // create command
        SqlCommand cmd = new SqlCommand(COMPANY_INSERT, conn);
        cmd.CommandType = System.Data.CommandType.StoredProcedure;

        // init command params
        cmd.Parameters.AddWithValue("CountryID", company.CountryID);
        cmd.Parameters.AddWithValue("StateID", company.StateID);
        cmd.Parameters.AddWithValue("CountyID", company.CountyID);
        **cmd.Parameters.AddWithValue("HasObituaries", company.HasObituaries);**
        cmd.Parameters.AddWithValue("Name", company.Name);
        **cmd.Parameters.AddWithValue("AlternateName", (string.IsNullOrEmpty(company.AlternateName)) ? null : company.AlternateName);**
        cmd.Parameters.AddWithValue("Address", (company.Address.Length == 0) ? null : company.Address);
        cmd.Parameters.AddWithValue("City", (company.City.Length == 0) ? null : company.City);
        cmd.Parameters.AddWithValue("ZipCode", (company.ZipCode.Length == 0) ? null : company.ZipCode);
        cmd.Parameters.AddWithValue("Phone", (company.Phone.Length == 0) ? null : company.Phone);
        cmd.Parameters.AddWithValue("Fax", (company.Fax.Length == 0) ? null : company.Fax);
        cmd.Parameters.AddWithValue("Website", (company.Website.Length == 0) ? null : company.Website);
        cmd.Parameters.AddWithValue("SearchURI", (company.SearchURI.Length == 0) ? null : company.SearchURI);
        cmd.Parameters.AddWithValue("AddedBy", (company.AddedBy == Guid.Empty) ? null : company.AddedBy.ToString());
        **cmd.Parameters.AddWithValue("Notes", company.Notes);**

        using (conn)
        {
            conn.Open();

            cmd.ExecuteNonQuery();
        }
    }

This same method has been working just fine, until I added the three new params. Now when this method runs it keeps giving me the error: “@HasObits is not a parameter for procedure sp_InsertNewRecord” If I comment that line out, it says the same error only with @AlternateName, then I comment that out and it says the same thing about @Notes, so I comment that out and then it inserts the record successfully.

If I had to guess, I would say that the SqlCommand is not registering the param for some reason. I can run the following SQL command in SQL Server 2008 and it works exactly how I expect:

exec sp_InsertNewRecord @CountryID = 1, @StateID = 13, @CountyID = 1, @Name = 'TESTING', @HasObits = 1, @Notes = 'testing notes', @AlternateName = 'alternate name'

I’m at a loss at this point. I’ve never had a problem like this and have spent about 5 hours now trying to find an answer to this, so any help would be greatly appreciated!

The DataTypes for the params being passed in (company.HasObits is a bool, company.AlternateName is a string, and company.Notes is a string).

Thank you in advance for your help! I’m very very frustrated by this and hoping someone can shed some light on this.

  • 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-05-31T23:56:39+00:00Added an answer on May 31, 2026 at 11:56 pm

    This problem was down to the hosting company moving database servers as I was testing the application and it was no longer pointing to the correct database anymore.

    All the code was/is correct (which makes me feel better), but it was just pointing to the wrong db server. I got an email about 5 hours later from the company telling me it was switched and that I need to update any references to the old server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a stored procedure that has to retrieve data from multiple tables something
I have an Oracle trigger which is calling a stored procedure that has PRAGMA
We have a SQL Server 2008 database that has stored procedures to handle reads/writes/etc.
I have a stored procedure that takes a user ID and calculates their balance
I have a stored procedure that takes no parameters, and it returns two fields.
I have a stored procedure that I want to call from within another, and
I have a stored procedure that logs some data, how can I call this
i have a stored procedure that performs a join of TableB to TableA :
I have a stored procedure that does, among other stuff, some inserts in different
I have a stored procedure that runs custom backups for around 60 SQL servers

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.