DS.WriteXml(@"D:\Hero.xml");将文件写入Xml
DS.ReadXml("Person.xml");
dataGrid1.DataSource=DS.Tables[0];绑定
sqlCmd=new SqlCommand();
sqlCmd.Connection=sqlCon;
sqlCon.Open();
for (int i=0;i<=DS.Tables[0].Rows.Count-1;i++)
{
//string str;
//str="Insert into Hero values('"+"0021"+"','"+"IT精英"+"','"+"性别"+"',"+"10"+",'"+"做菜"+"')";
sqlCmd.CommandText="Insert into Hero Values('"+dataGrid1[i,0].ToString()+"','"+dataGrid1[i,1].ToString()+"','"+dataGrid1[i,2].ToString()+"',"+dataGrid1[i,3].ToString()+",'"+dataGrid1[i,4].ToString()+"')";
sqlCmd.ExecuteNonQuery();写入数据库