当前现象:
webconfig 已经配置好2个数据库连接mysql,一个内网11aries库,一个内网10mydata 库;
后台配置好菜单/web/sysadmin/customview.html?objname=tb_mydata 表
连接点进去,能显示表头信息,也就是表的字段能看到,但表内容没显示。
跟踪调试,在Controller的 protected virtual MDataTable Select(GridConfig.SelectType st) 加断点,执行到 new MAction(CrossObjName) 时,CrossObjName 还是正确的mydata.tb_mydata ,但是执行过这句后,就catch 到
{"success":false,"msg":"V5.6.5.2 MySql.aries:check the tablename \"tb_mydata\" is exist? <br/>error:"}
也就是自己去找了 aries.tb_mydata 表,指定没有啊
怎么回事,谢谢秋大
首先:在Web.config里配置的数据库链接:必须是以 数据库名称+Conn 结尾的,才会开始收集表和数据库链接的对应关系:
具体代码在:
Aries.Core.Extend.CrossDb类里的DbTables属性,代码如下:
/// <summary> /// 所有数据库的表 /// </summary> public static Dictionary<string, Dictionary<string, string>> DbTables { get { if (_DbTablesDic.Count == 0) { lock (lockObj) { if (_DbTablesDic.Count == 0) { foreach (ConnectionStringSettings item in ConfigurationManager.ConnectionStrings) { string name = item.Name.ToLower(); if (!string.IsNullOrEmpty(name) && name.EndsWith("conn") && !badConn.Contains("," + name)) { if (DBTool.TestConn(name)) { string dbName = string.Empty; Dictionary<string, string> dic = DBTool.GetTables(name, out dbName); if (dic != null && dic.Count > 0 && !_DbTablesDic.ContainsKey(dbName)) { _DbTablesDic.Add(dbName, dic); _DbTypeDic.Add(dbName, DBTool.GetDalType(name)); _ConnDic.Add(dbName, name); } } else { badConn = "," + name; } } } } } } return _DbTablesDic; } }