Solved

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

Posted on 2013-06-15
8
417 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 62

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
 
LVL 62

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 62

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 62

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

864 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now