管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2024-09-05 95d9356edef73a1ad5b04e62b7aef6b77697a226
ExportMap/db/PostgreHelper.cs
@@ -28,11 +28,9 @@
        private string conStr = null;
        public PostgreHelper(DbEnum db)
        public PostgreHelper()
        {
            string str = ConfigurationManager.AppSettings["pgConn"];
            this.conStr = string.Format(str, db.ToString());
            this.conStr = ConfigurationManager.AppSettings["pgConn"];
        }
        /// <summary>
@@ -134,6 +132,32 @@
            }
        }
        public int GetIntScalar(string sql, params DbParameter[] args)
        {
            using (NpgsqlConnection con = new NpgsqlConnection(ConStr))
            {
                if (con.State != ConnectionState.Open)
                {
                    con.Open();
                }
                using (NpgsqlCommand cmd = new NpgsqlCommand(sql, con))
                {
                    if (args != null)
                    {
                        foreach (DbParameter arg in args)
                        {
                            cmd.Parameters.Add(arg);
                        }
                    }
                    object obj = cmd.ExecuteScalar();
                    return null == obj ? 0 : Convert.ToInt32(obj);
                }
            }
        }
        /// <summary>
        /// 执行SQL,返回影响行数
        /// </summary>
@@ -170,4 +194,4 @@
            return Regex.IsMatch(input, StrRegex, RegexOptions.IgnoreCase);
        }
    }
}
}