public DataTable getPropertysByPnumberFromLocalHost(string propertyIDs) { string[] propertyID = propertyIDs.Split('|'); string sql = ""; string wherestr = ""; if (propertyID.Length > 0) { for (int i = 0; i < propertyID.Length; i++) { //('AE9O-0184','AE9O-0183','AE9O-0189') wherestr = wherestr + "'" + propertyID[i] + "',"; } } wherestr = wherestr.Remove(wherestr.Length - 1, 1); sql = @"SELECT * from propertys WHERE propertyID in (" + wherestr + ")"; DataTable dt = new DataTable(); dt = Mysql_SqlHelper.ExcuteTable(sql); /* * if (MiddleWare == "1") * { * dt = MyCatfsg_SqlHelper.ExcuteTable(sql); * } * else * { * dt = Mysqlfsg_SqlHelper.ExcuteTable(sql); * } */ return(dt); }
/// <summary> /// 数据库连接操作,可替换为你自己的程序 /// </summary> /// <param name="ConnectionString">连接字符串</param> /// <returns></returns> public List <string> TestConnection(string serName) { List <string> lists = new List <string>(); switch (serName) { case "ERPconnStr": try { string sql = "select TABLE_NAME from all_tab_comments where ROWNUM <20"; DataTable dt = ERP_SqlHelper.ExcuteTable(sql); if (dt.Rows.Count <= 0) { lists.Add("连接数据库错误"); } else { for (int i = 0; i < dt.Rows.Count; i++) { lists.Add(dt.Rows[i]["TABLE_NAME"].ToString()); } } return(lists); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); lists.Add("连接数据库错误"); return(lists); } case "BESTconnStr": try { string sql = "Select Name TABLE_NAME From Master..SysDatabases order By Name"; DataTable dt = BEST_SqlHelper.ExcuteTable(sql, serName); if (dt.Rows.Count <= 0) { lists.Add("连接数据库错误"); } else { for (int i = 0; i < dt.Rows.Count; i++) { lists.Add(dt.Rows[i]["TABLE_NAME"].ToString()); } } return(lists); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); lists.Add("连接数据库错误"); return(lists); } case "BESTconnStr_KM": try { string sql = "Select Name TABLE_NAME From Master..SysDatabases order By Name"; DataTable dt = BEST_SqlHelper.ExcuteTable(sql, serName); if (dt.Rows.Count <= 0) { lists.Add("连接数据库错误"); } else { for (int i = 0; i < dt.Rows.Count; i++) { lists.Add(dt.Rows[i]["TABLE_NAME"].ToString()); } } return(lists); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); lists.Add("连接数据库错误"); return(lists); } case "MySqlconnStr": try { string sql = "SHOW TABLES; "; DataTable dt = Mysql_SqlHelper.ExcuteTable(sql); if (dt.Rows.Count <= 0) { lists.Add("连接数据库错误"); } else { for (int i = 0; i < dt.Rows.Count; i++) { lists.Add(dt.Rows[i]["TABLE_NAME"].ToString()); } } return(lists); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); lists.Add("连接数据库错误"); return(lists); } default: lists.Add("未知错误"); return(lists); } }