:   我的操作系统是XP   SP2   用VS2005写代码   数据库是SQL2000个人版我是一只菜菜鸟   请问SQL个人2000   在企业管理器里windows连接可以连上1到SQL连接就连不上了在VS2005里写的代码如下 
  USING   SYSTEM   .DETA.SQLCLIENT   
...   
SQLCONNECTION   CNN=NEW   SQLCONNECTION   () 
  CNN.CONNCTIONSTRING="DATA   SOURCE=XXXXX;INITAL   CATALOG=xxx;UID=xxxx;PWD=xxxxx"; 
  CNN.OPEN(); 
  然后返回的是最后那行错误   。sql无法打开请教原因   原来VS带2005客户端已经卸载   任何重新安装的SQL2000个人版   
而且在2000的企业管理器里   windows连接可以连上   1到SQ00L连接就不行鸟 
2000设置的双重登陆

解决方案 »

  1.   

    这是一个链接的例子 public DataTable GetAllAfficheDA()
            {
                try
                {
                    string strConnection = @"server=charry\SQLEXPRESS; database=db_ComPany; user id = sa; pwd = sa; ";
                    SqlConnection sqlCn = new SqlConnection(strConnection);                string strSql = "tb_AfficheGetAllAffiche";
                    SqlCommand sqlCmd = new SqlCommand(strSql, sqlCn);//不可以没有sqlCn参数?
                    sqlCmd.CommandText = "tb_AfficheGetAllAffiche";
                    sqlCmd.CommandType = CommandType.StoredProcedure;                
                    SqlDataAdapter sqlAda = new SqlDataAdapter(sqlCmd);                sqlCn.Open();
                    sqlCmd.ExecuteNonQuery();
                    sqlAda.Fill(dt);//有返回值的要添充
                    sqlCn.Close();
                    return dt;
                }
                catch (Exception ex)
                {
                    throw new Exception("数据读取出错!", ex);
                    return null;
                }
                finally
                {
                }
            }
      

  2.   

    tb_AfficheGetAllAffiche 是一个存储过程
    你可以写各selectcreate proc tb_AfficheGetAllAffiche
    as
    select * from 表名
      

  3.   

    DATA       SOURCE=XXXXX;INITAL       CATALOG=xxx;UID=xxxx;PWD=xxxxx"
    连接串有问题
    Provider=SQLOLEDB.1;Persist Security Info=False;uid=xxxx;Data Source=xxx;pwd=xxx;INITAL       CATALOG=xxx;应该加上provider=sqloledb.1;Persist Security Info=False;
      

  4.   

    才看到SqlConnection  
    command
    datareader
    dataadapter啥的现在还没看那