Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1440
  • Last Modified:

String must be exactly one character long.

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

0
kwh3856
Asked:
kwh3856
  • 3
  • 3
1 Solution
 
naspinskiCommented:
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.
0
 
Fernando SotoCommented:
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
0
 
kwh3856Author 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

0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
kwh3856Author 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

0
 
Fernando SotoCommented:
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
0
 
kwh3856Author 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.
0
 
Fernando SotoCommented:
Very good, glad it worked out.  ;=)
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now