page_Connection = new SqlConnection("server = localhost;Initial Catalog = userInfo; Integrated Security = True;");
大家帮我看看这句代码有问题么 为什么程序提示 Open失败

解决方案 »

  1.   

    string connectionString = "server=本地可.;database=数据库名;uid=帐号;pwd=密码";
      

  2.   

     page_Connection = new SqlConnection("server = localhost;Initial Catalog = userInfo; User Id = sa; Password = 1111;");
    也试过啦 没用啊 
    那个server  就等于localhost的话 程序能找到我在哪个数据库下的表么??  能么 》??感觉是server的问题 可是该怎么写啊
      

  3.   

    Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
    检查数据库配置
      

  4.   

    创建完链接之后,要用 对象名.open()打开数据库链接才行。
      

  5.   

    数据库配置里的什么 是myServeradress啊??
    能说明白点么?
      

  6.   

    就是OPEN的地方报错 我才知道连不上啊 大哥
      

  7.   

    在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)
    这个错误代码 麻烦哪位给看下
      

  8.   

    你的SQLserver配置有问题 
    设置 改为 混合登录模式 
    http://apps.hi.baidu.com/share/detail/17331500你确定你的 sa 用户组 是否开启了 
      

  9.   

    你在MSSQL 界面 登录用sa能进去??
    大你是在web里面 打不开 
    对吧?
      那就是你的 sqlhelper 的问题 
      

  10.   

    是在跑一个WEB程序的时候 在OPEN的地方报错 了 错误代码在上面 。
    sqlhelper是啥??
    如果那没问题 我那代码没问题??
      

  11.   


    估计是你的sqlhelper的问题。
    你还是检查下  帮不了你  给贴一个
    public class DBHelper
        {
            private static SqlConnection connection;
            public static SqlConnection Connection
            {
                get
                {
                    string connectionString = ConfigurationManager.ConnectionStrings["MyCommerce"].ConnectionString;
                    if (connection == null)
                    {
                        connection = new SqlConnection(connectionString);
                        connection.Open();
                    }
                    else if (connection.State == System.Data.ConnectionState.Closed)
                    {
                        connection.Open();
                    }
                    else if (connection.State == System.Data.ConnectionState.Broken)
                    {
                        connection.Close();
                        connection.Open();
                    }
                    return connection;
                }
            }        public static int ExecuteCommand(string safeSql)
            {
                SqlCommand cmd = new SqlCommand(safeSql, Connection);
                int result = cmd.ExecuteNonQuery();
                return result;
            }        public static int ExecuteCommand(string sql, params SqlParameter[] values)
            {
                SqlCommand cmd = new SqlCommand(sql, Connection);
                cmd.Parameters.AddRange(values);
                return cmd.ExecuteNonQuery();
            }        public static int GetScalar(string safeSql)
            {
                SqlCommand cmd = new SqlCommand(safeSql, Connection);
                int result = Convert.ToInt32(cmd.ExecuteScalar());
                return result;
            }        public static int GetScalar(string sql, params SqlParameter[] values)
            {
                SqlCommand cmd = new SqlCommand(sql, Connection);
                cmd.Parameters.AddRange(values);
                int result = Convert.ToInt32(cmd.ExecuteScalar());
                return result;
            }        public static SqlDataReader GetReader(string safeSql)
            {
                SqlCommand cmd = new SqlCommand(safeSql, Connection);
                SqlDataReader reader = cmd.ExecuteReader();
                return reader;
            }        public static SqlDataReader GetReader(string sql, params SqlParameter[] values)
            {
                SqlCommand cmd = new SqlCommand(sql, Connection);
                cmd.Parameters.AddRange(values);
                SqlDataReader reader = cmd.ExecuteReader();
                return reader;
            }        public static DataTable GetDataSet(string safeSql)
            {
                DataSet ds = new DataSet();
                SqlCommand cmd = new SqlCommand(safeSql, Connection);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(ds);
                return ds.Tables[0];
            }        public static DataTable GetDataSet(string sql, params SqlParameter[] values)
            {
                DataSet ds = new DataSet();
                SqlCommand cmd = new SqlCommand(sql, Connection);
                cmd.Parameters.AddRange(values);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(ds);
                return ds.Tables[0];
            }    }
      

  12.   

    你那个代码能不能把你的web.config也贴上来啊
      

  13.   

    连接字串这样写试试
     string constr = "Data source=.;DataBase=NodeMonitor;Integrated Security=True;Pooling=False";
      

  14.   

    我的数据库结构是
    SS-PC\SQLEXPRESS
    ss
    userInfo
    拜托
      

  15.   

    string constr = "Data source=SS-PC\SQLEXPRESS
    ;DataBase=ss;Integrated Security=True;Pooling=False";
    这样试试
      

  16.   

    database 我是的数据库名是么  
      

  17.   

    一定要用WINDOWS验证么 书上是SQL 验证啊 我是没问题  我女朋友怕会不认 啊
      

  18.   

    如果你的数据库登陆是混合验证模式也可以这样
    string constr = "Data source=SS-PC\SQLEXPRESS;DataBase=ss;uid=用户名;pwd=密码";
      

  19.   

    <appSettings>
       <add key="MsSql" value="Data Source=CSST-NEW;Initial Catalog=IClub;Integrated Security=True"/>
    </appSettings> 
    //web.config文件配置
    //写代码来获取文件中信息,比如:
    public class Common
    {
     private static string ConStr = string.Empty;
     public Common()
    {
     ConStr=ConfigurationManager.appsettings["MsSql"].toString();
    }
     public static SqlConnection sqlConnObject()

    return new SqlConnetion(ConStr);
    }  
    }
    还有就是你的数据库配置出了问题,可以(.aspx)直接拖一个sqlConnetionobject对象然后点小三角任务向导可完成配置。
      

  20.   

    1.连接字符串改成:string connectionString = "server=本地可.;database=数据库名;uid=帐号;pwd=密码";帐号可用sa,给sa设置密码,安全性设置里选择可启有SA
    2.打开协议,似乎是管道和TCP/TP
      

  21.   

    弱弱的问一句 你数据库放进sql server 里了么?
      

  22.   

    是不是用错命名空间了?OLE跟SQL的写法是不同的,不过都可以连SQL SERVER
      

  23.   

    "server=(local);database=dbname;uid=user;pwd=123456;"这个是SQLClient的写法,OLE的你可以百度一下
      

  24.   

    page_Connection = new SqlConnection("server = localhost;Initial Catalog = userInfo; Integrated Security = True;");
    改为
    page_Connection = new SqlConnection("Data Source= localhost;Initial Catalog = userInfo; Integrated Security = True;");试试
      

  25.   

    Data source=.  这样写,表示本机,如果你的sql是express版本,就写成Data source=.\express,数据库登录改成windows验证,这样就可以登上去了啊!!
      

  26.   


    同意.如果你的数据库是2000的话则用server=(local)
      

  27.   

    也可以在web.config中配置<add name="GiftMainDBConnection" connectionString="Server=.;Database=GiftMain;User Id=dbuser;Password=123456;Pooling=true;Min Pool Size=0;Max Pool Size=100;"/>