Example #1
0
        //public SqlServerDatabase(Connection connection) : base(connection) {}
        /// <summary>
        /// Specific initialization code. Hook method implemented.
        /// Load all selected database tables with object_ids
        /// </summary>
        /// <param name="connection"></param>
        protected override void LoadDataSetWithDataSourceMetadata(Connection connection)
        {
            if (connection == null)
                return;

            _sqlCn = (SqlConnection)connection.ConnectionObject;

            if (_ds == null)
                _ds = new DataSet();

            _ds.DataSetName = _sqlCn.Database;

            //get a table with all tables and its metadata in the database
            _da = new SqlDataAdapter(_tablesInDB, _sqlCn);
            if (_da != null)
            {
                _da.Fill(this._ds, "TablesInDb");
            }
        }
        /// <summary>
        /// 1. Make set the proper connection. Pass all parameters from UI.
        /// REMEMBER: The User doesn't have to know how to format a proper connection string.
        /// </summary>
        /// <param name="settings"></param>
        public void SetConnection(string server,string database,bool isIntegratedSecurity,string login,string password)
        {
            //create a connection object
               _cn = _df.MakeConnection();

               if (_cn == null)
                    throw new Exception("Cannot connect to your data source.");

               string _settings = _cn.ParseSettings(server, database, isIntegratedSecurity.ToString(), login, password);
               try
               {
                    //set connection settings and connect
                    if (!_cn.Connect(_settings))
                         throw new Exception("Cannot connect to your data source.");
               }
               catch { }
        }
Example #3
0
 /// <summary>
 /// Template constructor method.
 /// </summary>
 public void SetConnection(Connection connection)
 {
     //_cn = connection;
     //Template method, child must override details
     LoadDataSetWithDataSourceMetadata(connection);
 }
Example #4
0
 //hook method to be implemented by derived
 protected abstract void LoadDataSetWithDataSourceMetadata(Connection connection);
Example #5
0
 /// <summary>
 /// Create a Database setted with a concrete connection
 /// </summary>
 /// <returns></returns>
 public abstract Database MakeDB(Connection connection);