Click here to Skip to main content
15,885,870 members
Articles / Database Development / SQL Server

.NET Installer that Automatically Installs SQL 2005 Express

Rate me:
Please Sign up or sign in to vote.
4.77/5 (23 votes)
28 Jul 2008GPL35 min read 153.4K   6.2K   133  
This project enables developer to create a setup package that automatically installs SQL 2005 Express and restores database to it
								using System;
								using System.Collections;
                                using System.Collections.Generic;
                                using System.Data;
                                using System.Linq;
                                using System.Text;
                                using JohnKenedy.DataAccess;

                                namespace JohnKenedy.Samples
                                {
									 #region IEnumerator
                                    public class MProfitDistributionEnumerator : IEnumerator<MProfitDistributionEntity>
                                    {
                                        MProfitDistributionEntityCollection _Item = null;
                                        int _position = -1;

                                        public MProfitDistributionEnumerator(MProfitDistributionEntityCollection _item)
                                        {
                                            _Item = _item;

                                        }

                                        public void Dispose()
                                        {
                                        }

                                        public void Reset()
                                        {
                                            _position = -1;
                                        }

                                        public MProfitDistributionEntity Current
                                        {
                                            get
                                            {
                                                if (_position >= 0 && _position < _Item.Collection.Count)
                                                {
                                                    return _Item.Collection[_position];
                                                }
                                                return null;
                                            }
                                        }

                                        object IEnumerator.Current
                                        {
                                            get
                                            {
                                                if (_position >= 0 && _position < _Item.Collection.Count)
                                                {
                                                    return _Item.Collection[_position];
                                                }
                                                return null;
                                            }
                                        }

                                        public bool MoveNext()
                                        {
                                            _position += 1;
                                            if (_position >= _Item.Collection.Count)
                                            {
                                                _position = -1;
                                                return false;
                                            }
                                            return true;
                                        }
                                    }
                                    #endregion
                                    
                                    public class MProfitDistributionEntityCollection : IEnumerable<MProfitDistributionEntity>
                                    {
										#region Properties
                                        private string _TableName = "MProfitDistribution";
                                        private DataAccessTableFiller _Filler = null;
                                        public DataAccessTableFiller Filler
                                        {
                                            get
                                            {
                                                return _Filler;
                                            }
                                        }
                                        
                                        private IList<MProfitDistributionEntity> _Collection = new List<MProfitDistributionEntity>();
                                        public IList<MProfitDistributionEntity> Collection
                                        {
											get
											{
												return _Collection;
											}
                                        }
                                        
                                        private DataTable _LastSelectTable = null;
                                        public DataTable LastSelectTable
                                        {
											get
											{
												return _LastSelectTable;
											}
                                        }
                                        #endregion
                                        
                                        public MProfitDistributionEntityCollection()
                                        {
                                        }
                                        
                                        public MProfitDistributionEntity this[int _index]
                                        {
                                            get
                                            {
                                                if (_index < _Collection.Count)
                                                {
                                                    return _Collection[_index];
                                                }
                                                return null;
                                            }
                                            set
                                            {
                                                if (_index < _Collection.Count)
                                                {
                                                    _Collection[_index] = value;
                                                }
                                            }
                                        }
                                        
                                        #region IEnumerable
                                        public IEnumerator<MProfitDistributionEntity> GetEnumerator()
                                        {
                                            MProfitDistributionEnumerator _item = new MProfitDistributionEnumerator(this);
                                            return _item;
                                        }

                                        IEnumerator IEnumerable.GetEnumerator()
                                        {
                                            MProfitDistributionEnumerator _item = new MProfitDistributionEnumerator(this);
                                            return _item;
                                        }
                                        #endregion
                                        
                                        public void SetDataByTable(DataTable _table)
                                        {
                                            _Collection.Clear();
                                            foreach (DataRow _row in _table.Rows)
                                            {
                                                MProfitDistributionEntity _item = new MProfitDistributionEntity();
                                                _item.Filler.SetColumnValueByDataRow(_row);
                                                _Collection.Add(_item);
                                            }
                                        }

										public void GetDataAll(string _sort)
										{
											IDbCommand _com = DataAccessLayer.Manager[_TableName].GetDataAll(_sort);
											_LastSelectTable = DataAccessLayer.Manager[_TableName].ExecuteDataTableFromCommand(_com);
											
											SetDataByTable(_LastSelectTable);
										}
										
										public void GetDataByManual(string _sql, IDbDataParameter[] _params)
										{
											IDbCommand _com = DataAccessLayer.Manager[_TableName].GetDataByManual(_sql, _params);
											_LastSelectTable = DataAccessLayer.Manager[_TableName].ExecuteDataTableFromCommand(_com);
											
											SetDataByTable(_LastSelectTable);
										}
										
										public void GetDataBy(IList<string> _selectColumn, IList<KeyValuePair<string, object>> _pairFilter, string _sort)
										{
											IDbCommand _com = DataAccessLayer.Manager[_TableName].GetDataBy(_selectColumn, _pairFilter, _sort);
											_LastSelectTable = DataAccessLayer.Manager[_TableName].ExecuteDataTableFromCommand(_com);
											
											SetDataByTable(_LastSelectTable);
										}
										
										public void GetDataByWhere(IList<string> _selectColumn, string _sql, IDbDataParameter[] _parameters, string _sort)
										{
											IDbCommand _com = DataAccessLayer.Manager[_TableName].GetDataByWhere(_selectColumn, _sql, _parameters, _sort);
											_LastSelectTable = DataAccessLayer.Manager[_TableName].ExecuteDataTableFromCommand(_com);
											
											SetDataByTable(_LastSelectTable);
										}
										
										public MProfitDistributionEntity[] FilterLastSelectByTableFilter(string _filter)
										{
											DataRow[] _rows = _LastSelectTable.Select(_filter);
											MProfitDistributionEntity[] _results = new MProfitDistributionEntity[_rows.Length];
											for (int i=0; i<_rows.Length; i++)
											{
												foreach(MProfitDistributionEntity _item in _Collection)
												{
													if (_item.RowData == _rows[i])
													{
														_results[i] = _item;
														break;
													}
												}
											}
											return _results;
										}
										
										#region TreeModuleExtend
										protected MProfitDistributionEntity _TreeMProfitDistributionRoot = null;
										public void SetTreeMProfitDistributionRoot(MProfitDistributionEntity _root)
										{
											_TreeMProfitDistributionRoot = _root;
										}
										
										public MProfitDistributionEntity GetTreeMProfitDistributionRoot()
										{
											return _TreeMProfitDistributionRoot;
										}
										
										public long InsertTreeMProfitDistributionIdentityToRoot(MProfitDistributionEntity _detail)
										{
											return _detail.InsertTreeMProfitDistributionIdentityToRoot(_TreeMProfitDistributionRoot);
										}
										
										public int InsertTreeMProfitDistributionToRoot(MProfitDistributionEntity _detail)
										{
											return _detail.InsertTreeMProfitDistributionToRoot(_TreeMProfitDistributionRoot);
										}
										#endregion                            
                                    }
                                }

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
Singapore Singapore
I write code mostly in C#, VB.NET, PHP and Assembly.

Comments and Discussions