Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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

Posted on 2013-06-15
Medium Priority
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.
Question by:homeshopper
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 30

Expert Comment

by:Randy Downs
ID: 39250488
Maybe this will help

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

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


Author Comment

ID: 39250708
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 64

Accepted Solution

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);

Author Comment

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?
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.


Author Closing Comment

ID: 39251831
Thanks for the help.
LVL 64

Expert Comment

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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

609 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