同一个ip有三个name,是不是你连错实例了?

解决方案 »

  1.   

    [MiddleDB67-2]改为[MiddleDB67-3]或者[MiddleDB67]试试
      

  2.   


             protected void btnSave_Click(object sender, EventArgs e)
            {
                SqlParameter[] lsparam = 
                {
                    new SqlParameter("@server",YingSheName_500011.Text.Trim()),
                    new SqlParameter("@srvproduct",""),
                    new SqlParameter("@provider","SQLNCLI"),
                    new SqlParameter("@datasrc",ShuJuYuan_500011.Text.Trim())
                };           
                ExecuteCommand("sp_addlinkedserver",lsparam);
               
                SqlParameter[] lsLoginParam = 
                {
                    new SqlParameter("@rmtsrvname",YingSheName_500011.Text.Trim()),
                    new SqlParameter("@useself","true"),
                    new SqlParameter("@locallogin",null),
                    new SqlParameter("@rmtuser",txtLoginID.Text.Trim()),
                    new SqlParameter("@rmtpassword",txtPWD.Text.Trim())
                };            ExecuteCommand("sp_addlinkedsrvlogin", lsLoginParam);
                
            }        public static int ExecuteCommand(string procName,params SqlParameter[] values)
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = Connection;
                cmd.CommandText = procName;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddRange(values);
                int result = cmd.ExecuteNonQuery();
                Connection.Close();
                return result;
            }
      

  3.   

    YingSheName_500011 这个是什么东西?链接服务器预设就可以拉,你这是想动态设定?
      

  4.   

    因为这是客户要求的,YingSheName_500011这就是个TextBox,值就是MiddleDB67等
      

  5.   

    目标数据库用sa账号能正常登录,与云平台没什么关系
    我总感觉是你创建链接服务器的时候密码没输对,你在创建试试。
    --创建链接服务器 
    exec sp_addlinkedserver   'ITSV ', ' ', 'SQLOLEDB ', '远程服务器名或ip地址 ' 
    exec sp_addlinkedsrvlogin  'ITSV ', 'false ',null, '用户名 ', '密码 ' --查询示例 
    select * from ITSV.数据库名.dbo.表名 
      

  6.   

    你试一下用SSMS来实现看看能不能行,先别考虑用前端语言
      

  7.   

    问题找到了。
    exec sp_addlinkedsrvlogin  'ITSV ', 'false',null, '用户名 ', '密码 ' 这个地方我用的是true 。
    有什么区别呢?求解释?
      

  8.   

    sp_addlinkedsrvlogin [ @rmtsrvname = ] 'rmtsrvname' 
         [ , [ @useself = ] 'TRUE' | 'FALSE' | NULL ] 
         [ , [ @locallogin = ] 'locallogin' ] 
         [ , [ @rmtuser = ] 'rmtuser' ] 
         [ , [ @rmtpassword = ] 'rmtpassword' ] 
    A value of TRUE specifies that logins use their own credentials to connect to rmtsrvname, with the rmtuser and rmtpassword arguments being ignored. FALSE specifies that the rmtuser and rmtpassword arguments are used to connect to rmtsrvname for the specified locallogin. If rmtuser and rmtpassword are also set to NULL, no login or password is used to connect to the linked server.