いろいろ試行錯誤

調べものしたときの覚書きや、仕事でコーディングした時のメモ などなど…

テキストファイルから重複行削除≪OLEDB編≫

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\;Extended Properties=\"text;HDR=NO;FMT=Delimited\"") ;
            OleDbCommand cmd = new OleDbCommand("select distinct *  from Test.txt", con);
            con.Open();
            OleDbDataReader dr = cmd.ExecuteReader();
            int rowcount = 0;
            while (dr.Read() == true)
            {
                rowcount++;
                Console.WriteLine(dr.GetValue(0));
            }
            Console.WriteLine(rowcount);
            con.Close();
        }
    }
}