string server = newServer;
            string catalog = newCatalog;
            string connectionString = "server=" + server + ";Initial Catalog=" + catalog + ";Persist Security Info=False";
            SqlConnection connection = new SqlConnection(connectionString);
            try
            {
                connection.Open();
            }
            catch (Exception e)
            {
                return false;
            }
            return true;
这个里面我用工具连接的时候是可以连通的,但是用sqlconnection链接却连不通,有谁知道为什么吗

解决方案 »

  1.   

    推荐使用sql server身份验证,貌似楼主的连接字符串中少了Integrated Security=SSPI;
      

  2.   

    integrated security不是false吗?
      

  3.   

    http://www.cnblogs.com/lanse777/archive/2007/03/28/691757.html 但是你没写~~
      

  4.   

    http://www.cnblogs.com/lanse777/archive/2007/03/28/691757.html 但是你没写~~用用户登录是成功的。。
      

  5.   

    http://www.cnblogs.com/lanse777/archive/2007/03/28/691757.html 但是你没写~~用用户登录是成功的。。
    我知道,但是连接字符串有规定的写法~
      

  6.   

    你这个是对的,但是我看好多例子都是用Persist Security Info,真奇怪。谢谢
      

  7.   

    http://www.cnblogs.com/lanse777/archive/2007/03/28/691757.html 但是你没写~~用用户登录是成功的。。
    我知道,但是连接字符串有规定的写法~而且那个Persist Security Info=true也是错的。好奇怪