using System; using System.Collections.Generic; using System.Text; namespace DataCollectionSystem { public class RecordService { public static bool InertData( List datas) { try { string sql = string.Format("insert into TB_Card1 (Line1_Data,Line2_Data,Record_Time ) "); for (int i = 0; i < datas.Count;i++ ) { if(i!=datas.Count-1) sql += string.Format("SELECT {0},{1},'{2}' UNION ALL ", datas[i].Line1, datas[i].Line2, datas[i].Dt); else sql += string.Format("SELECT {0},{1},'{2}'", datas[i].Line1, datas[i].Line2, datas[i].Dt); } SqlServerDBHelper dbHelper = new SqlServerDBHelper(); if (dbHelper.ExecCommand(sql) > 0) { datas = null; return true; } else { return false; } } catch { // MessageBox.Show("未能正确安装AccessDatabaseEngine,请安装来自应用程序安装目录下的AccessDatabaseEngine.exe!"); return false; // throw new Exception(""); } } } }