VueWebApi/Tools/DapperHelper.cs
@@ -583,5 +583,64 @@
            }
            return result;
        }
        /// <summary>
        /// 执行sql执行语句,返回字符串
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static string sqlstr(String sql)
        {
            string result = "";
            using (IDbConnection conn = sqlConnection())
            {
                try
                {
                    if (result == "")
                    {
                        result = conn.Query<string>(sql).First();
                    }
                }
                catch (Exception ex)
                {
                    //创建日志记录组件实例
                    LogHelper.WriteLog(ex);
                    throw ex;
                }
                finally
                {
                    conn.Dispose();
                    conn.Close();
                }
            }
            return result;
        }
        public static DataTable lissql(string sql)
        {
            //sql语句
            using (IDbConnection conn = sqlConnection())
            {
                try
                {
                    DataTable table = new DataTable();
                    //var data = conn.ExecuteReader(sql, parm);
                    var res = conn.ExecuteReader(sql);//sql 存储过程
                    table.Load(res);
                    return table;
                }
                catch (Exception ex)
                {
                    //创建日志记录组件实例
                    LogHelper.WriteLog(ex);
                    throw ex;
                }
                finally
                {
                    conn.Dispose();
                    conn.Close();
                }
            }
        }
    }
}