best overloaded method match for 'Company.SetParameter(ref System.Data.SqlClient.SqlParameter, string)'

I am getting following errors:

best overloaded method match for 'Company.SetParameter(ref System.Data.SqlClient.SqlParameter, string)'
has some invalid arguments  line 203
Argument '1' must be passed with the 'ref' keyword line 203

SetParameter(cmd.Parameters[ParmName], ParmValue); //Line 203 error

Thanks in advance for any help given.
I have attached complete code as per attached file for clarity.
AttachedFile.txt
homeshopperAsked:
Who is Participating?
 
Fernando SotoConnect With a Mentor RetiredCommented:
Hi  homeshopper;

Try this to see if it resolves the problem.

var param = cmd.Parameters[ParmName];
SetParameter(ref param, ParmValue);
0
 
Randy DownsOWNERCommented:
Maybe this will help
http://msdn.microsoft.com/en-us/library/14akc2c7.aspx

The previous examples demonstrate what happens when you pass value types by reference. You can also use the ref keyword to pass reference types.

    static void ChangeByReference(ref Product itemRef)
    {
        // The following line changes the address that is stored in   
        // parameter itemRef. Because itemRef is a ref parameter, the 
        // address that is stored in variable item in Main also is changed.
        itemRef = new Product("Stapler", 99999);

        // You can change the value of one of the properties of 
        // itemRef. The change happens to item in Main as well.
        itemRef.ItemID = 12345;
    }

Open in new window

0
 
Fernando SotoRetiredCommented:
Hi  homeshopper;

Try using the ref keyword in the call as shown below.

SetParameter(ref cmd.Parameters[ParmName], ParmValue);

Open in new window

0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
homeshopperAuthor Commented:
Thanks,
get new error now:
A property or indexer may not be passed as an out or ref parameter line 208
SetParameter(ref cmd.Parameters[ParmName], ParmValue);// line 208
0
 
homeshopperAuthor Commented:
Thanks, That has cleared that problem.
Just now got to debug the rest of the code.
I have a dropdown that is not being populated.
Shall I award you the points, then later open another question
when I progresss with the debugging?
0
 
Fernando SotoRetiredCommented:
Hi  homeshopper;

Please do. The threads in the forum should only contain one question so that others searching the site can find similar issues. If more then one question is asked they may not be found on a search.

Thanks
0
 
homeshopperAuthor Commented:
Thanks for the help.
0
 
Fernando SotoRetiredCommented:
Not a problem, always glad to help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.