按照我下面的程序每次只能有一条记录,如何每循环一次就能插入记录,或者有没有更好的方法生成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+'")
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+'")
{
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+'") }
{
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+'")
执行语句...... }