Solved

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

Posted on 2013-06-15
8
420 Views
Last Modified: 2013-06-16
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
0
Comment
Question by:homeshopper
  • 4
  • 3
8 Comments
 
LVL 29

Expert Comment

by:Randy Downs
ID: 39250488
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
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39250661
Hi  homeshopper;

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

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

Open in new window

0
 

Author Comment

by:homeshopper
ID: 39250708
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39250720
Hi  homeshopper;

Try this to see if it resolves the problem.

var param = cmd.Parameters[ParmName];
SetParameter(ref param, ParmValue);
0
 

Author Comment

by:homeshopper
ID: 39250980
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
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39251307
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
 

Author Closing Comment

by:homeshopper
ID: 39251831
Thanks for the help.
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39251858
Not a problem, always glad to help.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question