我把oracle数据的emp表导入到一个新建的home表中,要求字段名不一样,但是对应的内容一样。但是导入到home表中的数据都是呈直角三角形斜边那样排列的,不知道什么原因求指导。 foreach (DataRow dr in dt.Rows)
            {                 for (int i = 0; i < list.Count; i++)
                {
                    for (int j = 0; j < list.Count; j++)
                    {
                        list3 .Add (  sql = "insert into home(" + ds.Tables ["home"].Columns [j] + ") values ('" + ds.Tables["tables"].Rows[i][j] + "')");
                       
                      //  Console.WriteLine("{0}", ds.Tables["home"].Rows[0][j]);
                    }
                    OracleCommand mycommand2 = new OracleCommand(list3 [i].ToString (), conn);
                    mycommand2.ExecuteNonQuery();                }
            }

解决方案 »

  1.   

    利用DataRow的值,应该就可以了吧。
    ds.Tables["tables"].Rows[i][j]这个有点莫名其妙啊
      

  2.   

    ds.Tables["tables"].Rows[i][j]的意思是读取datatable中名称为tables表第i行j列的数据可以利用datarow的值但是导入的数据结果是一样的都是斜着的;
    类似
    11
      11
         11
            ……
    这样的
      

  3.   

    你的list3装入了一组数据,但是你最后只取了list3[i]这个进行执行了啊。
    这里好像有问题吧。再一个就是,感觉你装入进list3的时候,sql组合好像不是很对啊。
    最终,一个字段一个字段的插入了成了,感觉。