Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello. I'm having an issue understanding how to send the data to a web service.
Error: Use of unassigned local variable 'myCCAuthRequest'
How do I properly prepare the string to send to the web service?
protected void ButtonContinuePayment_Click(object sender, EventArgs e)
        {      
            testwebservice.Request_Return_Parms rrRequest = new testwebservice.Request_Return_Parms();
            testwebservice.CCAuthRequest myCCAuthRequest;           

            string MerchantID = "MYMERCHID";
            decimal AuthorizationAmount = Convert.ToDecimal(litFee.Text);
            string OneStepTranType = "TRANTYP1";
            string ApplicationIDPrimary = litRegID2.Text;
            string ReturnURL = "https://mysite.com/Confirm.aspx";
            int AuthorizationAttemptLimit = 2;
            string ApplicationIDSecondary = "SecondID";  
            string ApplicationStateData = "StateData";
            string StyleSheetKey = "11f15af0a02999";
            string EmailAddressDeptContact = "jane.doe@mysite.com";

            try
            {                
                if (rrRequest.RequestReturnCode == 0)
                {   
//this is where I'm getting the error. Use of unassigned local variable 'myCCAuthRequest'	
                   rrRequest = myCCAuthRequest.AuthCapRequest(MerchantID, AuthorizationAmount, OneStepTranType, ApplicationIDPrimary, ReturnURL, AuthorizationAttemptLimit, ApplicationIDSecondary, ApplicationStateData, StyleSheetKey, EmailAddressDeptContact);
                }
            }
            catch
            {
                Response.Write("Error Processing payment");
            }
        }
Posted
Updated 26-Oct-12 9:32am
v3

1 solution

This has nothing to do with web services, or anything else really - other than basic coding.

You declare myCCAuthRequest in the second line of the method, then do nothing to give it a value until you use it in teh try...catch block.

The error message even tells you what you are doing wrong!
Use of unassigned local variable 'myCCAuthRequest'
You need to assign it a value - probably something to do with rrRequest, but that is up to you.
 
Share this answer
 
Comments
fjdiewornncalwe 26-Oct-12 17:05pm    
+5. Just what I found as well.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900