Beispiel #1
0
        /// <summary>
        /// 获取数据表
        /// </summary>
        /// <param name="TargetTable">目标表名</param>
        /// <returns>DataTable</returns>
        public DataTable GetDataTable(string connectionString, string TargetTable)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT * FROM " + TargetTable + "");
            return(MySqlHelper.ExecuteDataSet(connectionString, CommandType.Text, null).Tables[0]);
        }
Beispiel #2
0
        /// <summary>
        /// 根据唯一ID获取Dictionary<string,string>
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="pkName">字段主键</param>
        /// <param name="pkVal">字段值</param>
        /// <returns></returns>
        public Dictionary <string, string> GetHashtableById(string connectionString, string tableName, string pkName, string pkVal)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Select * From ").Append(tableName).Append(" Where ").Append(pkName).Append("=?ID");
            DataTable dt = MySqlHelper.ExecuteDataSet(connectionString, CommandType.Text, sb.ToString(), new MySqlParameter[] { new MySqlParameter("?ID", pkVal) }).Tables[0];

            return(DataTableHelper.DataTableToHashtable(dt));
        }