sqlConnection 只提供对数据库的连接要想对数据库进行操作还得用sqlCommand控件
打开 工具箱 把sqlConnection  和 sqlCommand 控件拖到工作区中 生成了sqlConnection1和sqlCommand1 右击sqlConnection1选中 属性 在它的属性列表中有ConnectionString点击下拉键头然后点 新建连接 在弹出的 数据连接属性 中配置好数据连接 确定返回,查看sqlCommand1属性 在Connetion 中点击下拉箭头选现有就可以了
代码如下
                        this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
                        this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
                        // 
                        // sqlConnection1
                        // 
                        this.sqlConnection1.ConnectionString = "workstation id=\"915-13\";packet size=4096;user id=sa;data source=306DUOMEITI;persi" +
                                "st security info=False";
                        // 
                        // sqlCommand1
                        // 
                        this.sqlCommand1.Connection = this.sqlConnection1;

解决方案 »

  1.   

            /// <summary>
            /// 公共连接
            /// </summary>
            private sqlConnection _Conn = new sqlConnection();
            /// <summary>
            /// 获取erp公共连接
            /// </summary>
            public sqlConnection Conn
            {
                get
                {
                    if (_Conn.ConnectionString =="") return initConn();
                    else return _Conn;}
                set { value = initConn(); }
            }
            private sqlConnection initConn()
            {
                _Conn = new OracleConnection(System.Configuration.ConfigurationManager.ConnectionStrings["erpConn"].ToString());
                if (_Conn.State != ConnectionState.Open) _Conn.Open();
                return _Conn;
            }
      

  2.   


    http://www.cnblogs.com/singlepine/archive/2005/10/15/255374.html