示例#1
0
        public static void ImportTables2(string saveMdbFile, string sourcemdbFile, List <StockTable> tables)
        {
            using (var connection = new OleDbConnection(string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}", saveMdbFile)))
            {
                connection.Open();
                foreach (var table in tables)
                {
                    if (table.IsSpace == true)
                    {
                        continue;
                    }
                    var sqlText = string.Format("INSERT INTO {0} SELECT {1} FROM [{2}].[{0}]", table.Name, string.Join(",", table.Fields.Select(e => e.Name).ToArray()), sourcemdbFile);
                    var rows1   = ADOSQLHelper.ExecuteNoQuery(connection, sqlText);
                    if (rows1 <= 0)
                    {
                        Console.WriteLine("插入数据失败");
                    }
                    //sqlText = string.Format("UPDATE {0} SET XZSDM = '{1}', XZSMC = '{2}' WHERE XZSDM IS NULL", table.Name, XZSDM, XZSMC);
                    //var rows2 = ADOSQLHelper.ExecuteNoQuery(connection, sqlText);
                    //if (rows1 == 0 || rows2 == 0 || rows1 != rows2)
                    //{
                    //    Console.WriteLine("导入表格数据失败!");
                    //}
                }

                connection.Close();
            }
        }
示例#2
0
        public static void SetXZS(string filePath, List <StockTable> tables, string XZSDM, string XZSMC)
        {
            using (var connection = new OleDbConnection(string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}", filePath)))
            {
                connection.Open();

                foreach (var table in tables)
                {
                    var sqlText = string.Format("UPDATE {0} SET XZSDM = '{1}', XZSMC = '{2}' WHERE XZSDM IS NULL", table.Name, XZSDM, XZSMC);
                    var rows    = ADOSQLHelper.ExecuteNoQuery(connection, sqlText);
                    if (rows <= 0)
                    {
                        Console.WriteLine("更新矢量中的行政市代码和行政市名称失败");
                    }
                }


                connection.Close();
            }
        }