/// <summary> /// 连接远程服务器 注:此方式创建经过测试发现目前无效,目前采用运维人员执行脚本,创建远程连接 /// </summary> /// <returns></returns> public bool RemoteConnection() { bool pIsTrue = false; using (DataSubmittedEntities db = new DataSubmittedEntities()) { //db.Database.ExecuteSqlCommand(" exec sp_addlinkedserver 'srv_lnk', '', 'SQLOLEDB', @ServerIp",new SqlParameter("@ServerIp","172.16.2.45")); //db.Database.ExecuteSqlCommand("exec sp_addlinkedsrvlogin 'srv_lnk', 'false',null, @UserName,@PassWord",new SqlParameter[]{new SqlParameter("@UserName","sa"),new SqlParameter("@PassWord","tayh@2013")}); db.SP_LinkServer(config["IP"], config["UserName"], config["PassWord"]); pIsTrue = true; } return pIsTrue; }