A Repasky

A Repasky

  • NA
  • 231
  • 184.2k

Code in VS2012 does not work but works in VS2010

Mar 21 2013 3:42 PM
 

Here is code that I have used over and over in other programs to create a comma delimited file.  I add it to a record for a number value column.  The code in yellow does not work in VS2012.  So I converted it back to VS2010 and it works.  It was in VS2010 and I converted it to VS2012.  I did not realize right away that the numbered columns did not have a value anymore.    I tried lots of things to get this to work. 

Thank you for anyone that can help on this.  I am supposed to do my development in VS2012.

arep 

                  for (int fcnt = 0; fcnt < dr.FieldCount; fcnt++)

                  {

                     if (fcnt == 21 && name == "Medical")

                     {

                        paidamt = paidamt + (decimal)dr.GetValue(fcnt);

                     }

 

                     //Handle strings

                     if (dr.GetValue(fcnt).GetType() == typeof(string))

                     {

                        sb.Append("\"");

                        sb.Append(dr.GetValue(fcnt));

                        sb.Append("\"");

                     }

                     //Handle numbers

                     else if (dr.GetValue(fcnt).GetType() == typeof(decimal))

                        sb.Append((double)(dr.GetDecimal(fcnt)));

 

                        //Handle dates

                     else if (dr.GetValue(fcnt).GetType() == typeof(int))

                     {

                        sb.Append("\"");

                        sb.Append(dr.GetInt32(fcnt).ToDate());

                        sb.Append("\"");

                     }

                     if (fcnt != dr.FieldCount - 1) sb.Append(",");

                  }

                  sw.WriteLine(sb.ToString());  // Print data rows

                  sb.Clear();

 

                  reccnt++;

               }

 


Answers (1)