导入数据库中
1.txt对应表A
2.txt对应表Bselect id from A where id not in (select id from B)

解决方案 »

  1.   

    上面的是一种方法,还可以不通过数据库:
    1.先把2。txt中的内容读到一个ArrayList对象中;
    2.然后一行一行读取1。txt文件,读一行判断一下,在ArrayList对象中存不存在该字符串,如果不存在,就写入3。txt读取文件的代码:
    string FILE_NAME="路径+1.txt";
    if(!File.Exists(FILE_NAME))
    {
        MessageBox("该文件不存在");
        return;
    }
    StreamReader sr=new StreamReader(FILE_NAME,Encoding.Default);
    while(sr.Peek()>-1)
    {
        string strRead=sr.ReadLine();
    }
      

  2.   

    Edison621(柏拉图的永恒)的方法可以
      

  3.   

    private ArrayList GetResult(){
    ArrayList result = new ArrayList();
    ArrayList txt1   = new ArrayList();
    ArrayList txt2   = new ArrayList(); StreamReader file1 = new StreamReader("1.txt");
    StreamReader file2 = new StreamReader("2.txt"); string file1String = null;
    file1String = file1.ReadLine();
    while(file1String != null){
    txt1.Add(file1String);
    file1String = file1.ReadLine();
    }
    file1.Close(); string file2String = null;
    file2String = file2.ReadLine();
    while(file2String != null){
    txt2.Add(file2String);
    file2String = file2.ReadLine();
    }
    file2.Close(); foreach(string temp1 in txt1){
    bool isHas = false;
    foreach(string temp2 in txt2){
    if(temp1 == temp2){
    isHas = true;
    break;
    }
    } if(isHas == true){
    continue;
    }else{
    result.Add(temp1);
    }
    } return result;
    }
      

  4.   

    将2读如一个数组中,
    然后将一一行一行的读,in  2
    则COntinue,OtherWise  insert..