public static bool InitTableSchemaFromSql(DataTable table, string sql, string paramvalue, string pageinfo, string dsname, string alias) { if (table == null || sql == null || sql.Equals("")) { return(false); } DataServices.OpenSql(table, sql, paramvalue, pageinfo, dsname); try { TableUtil.SetProperty(table, SysConstant.scSQL, sql); TableUtil.SetProperty(table, SysConstant.scParamValue, paramvalue); TableUtil.SetProperty(table, SysConstant.scBindAlias, alias); TableUtil.SetProperty(table, SysConstant.scPageManager, new PageManager(table)); TableUtil.SetProperty(table, SysConstant.scPrimaryKey, ""); DataColumn column; RuleColumn rcolumn; int count = table.Columns.Count; for (int i = 0; i < count; i++) { column = table.Columns[i]; rcolumn = RuleColumn.FromDataColumn(column); rcolumn.WhereOpt = "n"; TableUtil.SetProperty(column, SysConstant.scRuleColumn, rcolumn); } return(true); } catch (Exception e) { throw new Exception("SDP-ST02 填充元数据出错:" + e.Message); } }