Trim(',')的作用去除最有一个','

public bool XMLDataImport()
        {

List<string> sqllist = new List<string>();
            try
            {
                XmlDocument x = new XmlDocument();
                x.Load(txtFilePath.Text);///xml路径

foreach (XmlNode xn in x.ChildNodes)
                {

foreach (XmlNode xn1 in xn.ChildNodes)
                    {
                        string sql = "";
                        string insertValueString = "";
                        string insertColumnString = "";
                        foreach (XmlNode xn2 in xn1.ChildNodes)
                        {
                            ///读取信息 然后导入到数据库
                            insertValueString += string.Format("'{0}',", xn2.InnerText.ToString());
                            insertColumnString += string.Format("{0},", xn2.Name.ToString());
                        }
                        insertColumnString = insertColumnString.Trim(',');
                        insertValueString = insertValueString.Trim(',');
                        sql = string.Format(@"insert into {0}({1}) values({2})", txt_tablename.Text, insertColumnString, insertValueString);
                        sqllist.Add(sql);
                    }

}
                DALUse.ExecuteSqlTran(sqllist.ToArray());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            return true;
        }

上一篇:js之按键总结


下一篇:移动端click事件延迟300ms的原因以及解决办法[转载]