Procedure or function 'UpdatePHICounter' expects parameter '@ID', which was not supplied.

I am trying to update a record in a table where I thought I was supplying the one variable that it needs.  Can someone point out what I am blind to?

Here is my SQL Procedure:
------------------------------------------------

USE [12312]
GO
/****** Object:  StoredProcedure [dbo].[UpdatePHICounter]    Script Date: 11/06/2008 23:27:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Proc [dbo].[UpdatePHICounter]

@ID decimal


AS
BEGIN
SET NOCOUNT ON

UPDATE [DRRPHICntr]

SET ID = @ID


SET NOCOUNT OFF
End


Here is my C# Code:
-------------------------------------------------------------------------------------------------

///  ---------------   Write Updated Counter Back to Database
     

            SqlConnection UpdateNewPHICntrConn;
            UpdateNewPHICntrConn = new SqlConnection();
            UpdateNewPHICntrConn.ConnectionString = ConfigurationManager.ConnectionStrings["HIPAAv2ConnectionString"].ConnectionString;
            SqlCommand Updcmd;
            UpdateNewPHICntrConn.Open();

            Updcmd = new SqlCommand("UpdatePHICounter", UpdateNewPHICntrConn);
            Updcmd.CommandType = CommandType.StoredProcedure;
            id = Convert.ToDecimal(Session.Contents["id"].ToString());
            Updcmd.Parameters.Add("@ID", SqlDbType.Decimal).Value = id;
 
            Updcmd.Parameters.Clear();

           

            // Write Updated Counter Data
            Updcmd.ExecuteNonQuery();-----------------------------------Error Occurs Here

            if (UpdateNewPHICntrConn != null)
            {
                UpdateNewPHICntrConn.Close();
            }
kwh3856OwnerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

appariCommented:
try changing

Updcmd.Parameters.Add("@ID", SqlDbType.Decimal).Value = id;

to

Updcmd.Parameters.Add("@ID", SqlDbType.Decimal);
Updcmd.Parameters("@ID").Value = id;

or

Updcmd.Parameters.AddWithValue("@ID", id);
0
kwh3856OwnerAuthor Commented:
Tried this one and got error
Updcmd.Parameters.Add("@ID", SqlDbType.Decimal);
Updcmd.Parameters("@ID").Value = id;-----------------------------error property used like a method

 
 
 Tried this one
 Updcmd.Parameters.AddWithValue("@ID", id);
Still get
Procedure or function 'UpdatePHICounter' expects parameter '@ID', which was not supplied.
 
 
0
kwh3856OwnerAuthor Commented:
I tried commenting this line
Updcmd.Parameters.Clear();

and I get this error message:
Invalid object name 'DRRPHICntr'.
 
 
Here is the SQL Stored Procedure:

USE [123123]
GO
/****** Object: StoredProcedure [dbo].[UpdatePHICounter] Script Date: 11/06/2008 23:27:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Proc [dbo].[UpdatePHICounter]
@ID decimal
 
AS
BEGIN
SET NOCOUNT ON
UPDATE [DRRPHICntr]
SET ID = @ID
 
SET NOCOUNT OFF
End
0
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

appariCommented:
did you try running the stored procedure from query analyzer?
if you are able to run it without any errors check if the user id using in your ASP.Net application has permissions on the table or not
0
appariCommented:
and
Updcmd.Parameters("@ID").Value = id;-----------------------------
should be
Updcmd.Parameters["@ID"].Value = id;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kwh3856OwnerAuthor Commented:
That did the trick.  Thank you very much.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.