Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 813295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:20:08+00:00 2026-05-15T01:20:08+00:00

Here is the code for my simple parsing application. I am getting an error

  • 0

Here is the code for my simple parsing application. I am getting an error that states ‘No mapping exists from type System.Text.RegularExpressions.Match to a known managed provider native type’. This started to occur when I switched from using Split(‘_’) to RegEx.Match for defining RNumberE, RNumberD, etc. Any guidance is appreciated.

using System; 
using System.Data; 
using System.Data.SQLite; 
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;


namespace CMMDataParser 
{ 
    internal class Program 
    {


        public static List<string> GetImportedFileList()
        {
            List<string> ImportedFiles = new List<string>();
            using (SqlConnection connect = new SqlConnection(@"Server=SERVER;Database=RX_CMMData;Integrated Security=YES"))
            {
                connect.Open();
                using (SqlCommand fmd = connect.CreateCommand())
                {

                    fmd.CommandText = @"SELECT FileName FROM CMMData;";
                    fmd.CommandType = CommandType.Text;
                    SqlDataReader r = fmd.ExecuteReader();
                    while (r.Read())
                    {
                        ImportedFiles.Add(Convert.ToString(r["FileName"]));

                    }
                }
            }
            return ImportedFiles;
        } 




        private static void Main(string[] args) 
        {


            Console.Title = "John Deere CMM Data Parser";
            Console.WriteLine("Preparing CMM Data Parser... done");
            Console.WriteLine("Scanning for new CMM data...");
            Console.ForegroundColor = ConsoleColor.Gray;

            using (SqlConnection con = new SqlConnection(@"Server=FRXSQLDEV;Database=RX_CMMData;Integrated Security=YES"))
            {


                con.Open();

                using (SqlCommand insertCommand = con.CreateCommand())
                {
                    Console.WriteLine("Connecting to SQL server...");
                    SqlCommand cmdd = con.CreateCommand();
                    string[] files = Directory.GetFiles(@"C:\Documents and Settings\js91162\Desktop\CMM WENZEL\", "*_*_*.txt", SearchOption.AllDirectories);
                    List<string> ImportedFiles = GetImportedFileList();
                    insertCommand.Parameters.Add(new SqlParameter("@FeatType", DbType.String));
                    insertCommand.Parameters.Add(new SqlParameter("@FeatName", DbType.String));
                    insertCommand.Parameters.Add(new SqlParameter("@Axis", DbType.String));
                    insertCommand.Parameters.Add(new SqlParameter("@Actual", DbType.Decimal));
                    insertCommand.Parameters.Add(new SqlParameter("@Nominal", DbType.Decimal));
                    insertCommand.Parameters.Add(new SqlParameter("@Dev", DbType.Decimal));
                    insertCommand.Parameters.Add(new SqlParameter("@TolMin", DbType.Decimal));
                    insertCommand.Parameters.Add(new SqlParameter("@TolPlus", DbType.Decimal));
                    insertCommand.Parameters.Add(new SqlParameter("@OutOfTol", DbType.Decimal));

                    foreach (string file in files.Except(ImportedFiles))

                    {
                        var FileNameExt1 = Path.GetFileName(file);
                        cmdd.Parameters.Clear();
                        cmdd.Parameters.Add(new SqlParameter("@FileExt", FileNameExt1));
                        cmdd.CommandText =
                            @" 
                    IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'RX_CMMData' AND TABLE_NAME = 'CMMData')) BEGIN SELECT COUNT(*) FROM CMMData WHERE FileName = @FileExt; END";



                        int count = Convert.ToInt32(cmdd.ExecuteScalar());
                        con.Close();
                        con.Open();

                        if (count == 0)
                        {




                                Console.WriteLine("Preparing to parse CMM data for SQL import...");
                                if (file.Count(c => c == '_') > 5) continue;

                                insertCommand.CommandText =
                                    @"
                    INSERT INTO CMMData  (FeatType, FeatName, Axis, Actual, Nominal, Dev, TolMin, TolPlus, OutOfTol, PartNumber, CMMNumber, Date, FileName) 
                    VALUES     (@FeatType, @FeatName, @Axis, @Actual, @Nominal, @Dev, @TolMin, @TolPlus, @OutOfTol, @PartNumber, @CMMNumber, @Date, @FileName);";




                                string FileNameExt = Path.GetFullPath(file);


                                string RNumber = Path.GetFileNameWithoutExtension(file);
                                int index2 = RNumber.IndexOf("~");
                                Match RNumberE = Regex.Match(RNumber, @"^(R|L)\d{6}(COMP|CRIT|TEST|SU[1-9])(?=_)", RegexOptions.IgnoreCase);

                                Match RNumberD = Regex.Match(RNumber, @"(?<=_)\d{3}[A-Z]\d{4}|\d{3}[A-Z]\d\w\w\d(?=_)", RegexOptions.IgnoreCase);

                                Match RNumberDate = Regex.Match(RNumber, @"(?<=_)\d{8}(?=_)", RegexOptions.IgnoreCase);

                                if (RNumberD.Value == @"") continue;
                                if (RNumberE.Value == @"") continue;
                                if (RNumberDate.Value == @"") continue;
                                if (index2 != -1) continue;


                            /*  string RNumberE = RNumber.Split('_')[0];

                              string RNumberD = RNumber.Split('_')[1];
                              string RNumberDate = RNumber.Split('_')[2]; */

                                DateTime dateTime = DateTime.ParseExact(RNumberDate.Value, "yyyyMMdd", Thread.CurrentThread.CurrentCulture);
                                string cmmDate = dateTime.ToString("dd-MMM-yyyy");


                                string[] lines = File.ReadAllLines(file);
                                bool parse = false;

                                foreach (string tmpLine in lines)
                                {


                                    string line = tmpLine.Trim();
                                    if (!parse && line.StartsWith("Feat. Type,"))
                                    {
                                        parse = true;
                                        continue;
                                    }
                                    if (!parse || string.IsNullOrEmpty(line))
                                    {
                                        continue;
                                    }

                                    Console.WriteLine(tmpLine);
                                    foreach (SqlParameter parameter in insertCommand.Parameters)
                                    {
                                        parameter.Value = null;
                                    }

                                    string[] values = line.Split(new[] { ',' });

                                    for (int i = 0; i < values.Length - 1; i++)
                                    {
                                        SqlParameter param = insertCommand.Parameters[i];
                                        if (param.DbType == DbType.Decimal)
                                        {
                                            decimal value;
                                            param.Value = decimal.TryParse(values[i], out value) ? value : 0;
                                        }
                                        else
                                        {
                                            param.Value = values[i];
                                        }
                                    }


                                    insertCommand.Parameters.Add(new SqlParameter("@PartNumber", RNumberE));
                                    insertCommand.Parameters.Add(new SqlParameter("@CMMNumber", RNumberD));
                                    insertCommand.Parameters.Add(new SqlParameter("@Date", cmmDate));
                                    insertCommand.Parameters.Add(new SqlParameter("@FileName", FileNameExt));
                                    insertCommand.ExecuteNonQuery();

                                      insertCommand.Parameters.RemoveAt("@PartNumber");
                                     insertCommand.Parameters.RemoveAt("@CMMNumber");
                                     insertCommand.Parameters.RemoveAt("@Date");
                                    insertCommand.Parameters.RemoveAt("@FileName");

                                }


                            }

                                }  
                        Console.WriteLine("CMM data successfully imported to SQL database...");

                    }
                    con.Close();

            }
        } 
    } 
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:20:09+00:00Added an answer on May 15, 2026 at 1:20 am

    In the original code, RNumberD etc are string – most code (SqlParameter being the most likely) can handle this. In the revised code, it is a regex Match, which is a complex object representing the full state of a match, not just the matched string. I expect you simply need to use RNumberD.Value (the string of the matched text) in place of just RNumberD when adding it as a (sql) parameter:

    insertCommand.Parameters.Add(new SqlParameter("@CMMNumber", RNumberD.Value));
    

    (etc)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 443k
  • Answers 443k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You should use a white-list approach. When you display the… May 15, 2026 at 6:10 pm
  • Editorial Team
    Editorial Team added an answer From your numbers, I guess that GC is probably not… May 15, 2026 at 6:10 pm
  • Editorial Team
    Editorial Team added an answer Very simple: DoCmd.OpenForm kfrmArt,acNormal,,,,acDialog This will stop all processing the… May 15, 2026 at 6:10 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.