?
Solved

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

Posted on 2013-06-15
8
Medium Priority
?
426 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 30

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 64

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 64

Accepted Solution

by:
Fernando Soto earned 2000 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 64

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 64

Expert Comment

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview
Suggested Courses

829 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