按照我下面的程序每次只能有一条记录,如何每循环一次就能插入记录,或者有没有更好的方法生成sql语.
for (int i = 0; i < nodes3.Count; i++)
            {
                if (nodes3[i].HasChildNodes)
                {
                    for (int j = 0; j < nodes3[i].ChildNodes.Count; j++)
                    {
                        if ((nodes3[i].ChildNodes[j].Name)== "R-E_Type") 
                        {
                          strType = nodes3[i].ChildNodes[j].InnerText;
                        }
                        if((nodes3[i].ChildNodes[j].Name)== "Surface")
                        {
                            strSurface=nodes3[i].ChildNodes[j].InnerText;
                        }
                 }
             }
strSQL=insert into retable(type,surface)values("'+strType +'","'+strsurface+'")

解决方案 »

  1.   

    for (int i = 0; i < nodes3.Count; i++)
                {
                    if (nodes3[i].HasChildNodes)
                    {
                        for (int j = 0; j < nodes3[i].ChildNodes.Count; j++)
                        {
                            if ((nodes3[i].ChildNodes[j].Name)== "R-E_Type") 
                            {
                              strType = nodes3[i].ChildNodes[j].InnerText;
                            }
                            if((nodes3[i].ChildNodes[j].Name)== "Surface")
                            {
                                strSurface=nodes3[i].ChildNodes[j].InnerText;
                            }
                     }
    strSQL += insert into retable(type,surface)values("'+strType +'","'+strsurface+'")             }
      

  2.   

    可能我没有说清楚,按照你的方法,所有strtype和strsurface的都被拼出来了.我想要的是循环一次执行一次SQL语句,strtype和strsurface有很多值将被读出,我想读出一个值执行一次,而不是全部读出才执行
      

  3.   

    for (int i = 0; i < nodes3.Count; i++)
                {
                    if (nodes3[i].HasChildNodes)
                    {
                        for (int j = 0; j < nodes3[i].ChildNodes.Count; j++)
                        {
                            if ((nodes3[i].ChildNodes[j].Name)== "R-E_Type") 
                            {
                              strType = nodes3[i].ChildNodes[j].InnerText;
                            }
                            if((nodes3[i].ChildNodes[j].Name)== "Surface")
                            {
                                strSurface=nodes3[i].ChildNodes[j].InnerText;
                            }
                     }
    strSQL = insert into retable(type,surface)values("'+strType +'","'+strsurface+'")
    执行语句......             }