We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

String must be exactly one character long.

Medium Priority
1,506 Views
Last Modified: 2013-12-17
I keep getting this error message but I am not sure why it is erroring out this way.  Any ideas are greatly appreciated.

// setup foreach loop to lookup insurance comp npi and adress info
                    var ecinscomps = from ins in dceClinicalWorks.insurances
                           where ins.insId == patient.p.insId
                           select new {ins};
 
                    // Process each row of the result set in the foreach loop
                    foreach (var insurance in dceClinicalWorks.insurances)--------debug highlights the word "in" in the error message
                    {
                        myPatIns.MPI = initGuid;
                        myPatIns.ProviderNPI = patient.d.doctorID;
 
 
                        int myInsId;
                        if (Int32.TryParse(patient.p.insId.ToString(), out myInsId))
                        {
                            // Success! myInt now contains the numeric value of myString
                            myPatIns.Id = myInsId.ToString();
                        }
                        else
                        {
                            // Failed! MyInt is not defined.
                        }
    
                        myPatIns.GroupId = patient.p.insgroupno;
                        //myPatIns.CoPay = patient.p.inscopay;
                        myPatIns.ADDRESS_1 = insurance.insuranceaddress;
                        myPatIns.ADDRESS_2 = insurance.insuranceaddress2;
                        myPatIns.CITY = insurance.insurancecity;
                        myPatIns.STATE = insurance.insurancestate;
                        myPatIns.ZIP = insurance.insurancezip;

Open in new window

Comment
Watch Question

my guess is that 'insurance' also the name of a class, so the compiler is getting confused try changing it to 'ins' or something like that.

For example, you cant declare and Integer named 'int', etc.
Fernando SotoRetired
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Hi Kenny;

In this statement:

 // Process each row of the result set in the foreach loop
foreach (var insurance in dceClinicalWorks.insurances)--------debug highlights the word "in" in the error
{

The result set is ecinscomps so the line of code should be as follows:

foreach (var insurance in ecinscomps)

Have a great day;
Fernando
kwh3856Owner

Author

Commented:
naspinski,
Changed the code and still get the same error message.  Here is my changed code.

// setup foreach loop to lookup insurance comp npi and adress info
                    var ecinscomps = from ecins in dceClinicalWorks.insurances
                           where ecins.insId == patient.p.insId
                           select new {ecins};
 
                    // Process each row of the result set in the foreach loop
                    foreach (var insur in dceClinicalWorks.insurances)
                    {
                        myPatIns.MPI = initGuid;
                        myPatIns.ProviderNPI = patient.d.doctorID;
 
 
                        int myInsId;
                        if (Int32.TryParse(patient.p.insId.ToString(), out myInsId))
                        {
                            // Success! myInt now contains the numeric value of myString
                            myPatIns.Id = myInsId.ToString();
                        }
                        else
                        {
                            // Failed! MyInt is not defined.
                        }
    
                        myPatIns.GroupId = patient.p.insgroupno;
                        //myPatIns.CoPay = patient.p.inscopay;
                        
                        myPatIns.ADDRESS_1 = insur.insuranceaddress;
                        myPatIns.ADDRESS_2 = insur.insuranceaddress2;
                        myPatIns.CITY = insur.insurancecity;
                        myPatIns.STATE = insur.insurancestate;
                        myPatIns.ZIP = insur.insurancezip;
                        myPatIns.PHONE = insur.insurancephone;

Open in new window

kwh3856Owner

Author

Commented:
Fernando,
That worked but now I cannot acces my fields from the table.  I get the squiggly lines under
the insur.
What should I replace the insur. with?
I tried insuranc. and that did not work.
I tried ecinscoms and that did not work either.
Any ideas?
Thanks
Kenny
 

 // setup foreach loop to lookup insurance comp npi and adress info
                    var ecinscomps = from ecins in dceClinicalWorks.insurances
                           where ecins.insId == patient.p.insId
                           select new {ecins};
 
                    // Process each row of the result set in the foreach loop
                    foreach (var insurance in ecinscomps)
 
                    {
                        myPatIns.MPI = initGuid;
                        myPatIns.ProviderNPI = patient.d.doctorID;
 
 
                        int myInsId;
                        if (Int32.TryParse(patient.p.insId.ToString(), out myInsId))
                        {
                            // Success! myInt now contains the numeric value of myString
                            myPatIns.Id = myInsId.ToString();
                        }
                        else
                        {
                            // Failed! MyInt is not defined.
                        }
    
                        myPatIns.GroupId = patient.p.insgroupno;
                        //myPatIns.CoPay = patient.p.inscopay;
                        
                        
                        myPatIns.ADDRESS_1 = insur.insuranceaddress;----squiggly under insur.
                        myPatIns.ADDRESS_2 = insur.insuranceaddress2;
                        myPatIns.CITY = insur.insurancecity;
                        myPatIns.STATE = insur.insurancestate;

Open in new window

Retired
CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
Hi Kenny;

// If this is what you did try, "I tried insuranc. and that did not work." you are missing
// and e at the end of the name

// If insur is comming from the Linq query then you should be using the variable insurance
// which was declared in the foreach loop that holds a single instance of the result set.    
myPatIns.ADDRESS_1 = insurance.insuranceaddress;
myPatIns.ADDRESS_2 = insurance.insuranceaddress2;
myPatIns.CITY = insurance.insurancecity;
myPatIns.STATE = insurance.insurancestate;

Fernando

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
kwh3856Owner

Author

Commented:
Fernando,
Thank you that was it.  I was just missing the ecsins that I needed to include it.
insurance.ecins.
The fields then came up.
Fernando SotoRetired
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Very good, glad it worked out.  ;=)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.