Click here to Skip to main content
15,886,584 members
Articles / Database Development / SQL Server

.NET Installer that automatically installs MSDE

Rate me:
Please Sign up or sign in to vote.
3.63/5 (7 votes)
26 Jul 2008GPL36 min read 45.4K   557   30  
This project enables developers to create a setup package that automatically installs MSDE and attaches database
								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 MHistoryEnumerator : IEnumerator<MHistoryEntity>
                                    {
                                        MHistoryEntityCollection _Item = null;
                                        int _position = -1;

                                        public MHistoryEnumerator(MHistoryEntityCollection _item)
                                        {
                                            _Item = _item;

                                        }

                                        public void Dispose()
                                        {
                                        }

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

                                        public MHistoryEntity 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 MHistoryEntityCollection : IEnumerable<MHistoryEntity>
                                    {
										#region Properties
                                        private string _TableName = "MHistory";
                                        private DataAccessTableFiller _Filler = null;
                                        public DataAccessTableFiller Filler
                                        {
                                            get
                                            {
                                                return _Filler;
                                            }
                                        }
                                        
                                        private IList<MHistoryEntity> _Collection = new List<MHistoryEntity>();
                                        public IList<MHistoryEntity> Collection
                                        {
											get
											{
												return _Collection;
											}
                                        }
                                        
                                        private DataTable _LastSelectTable = null;
                                        public DataTable LastSelectTable
                                        {
											get
											{
												return _LastSelectTable;
											}
                                        }
                                        #endregion
                                        
                                        public MHistoryEntityCollection()
                                        {
                                        }
                                        
                                        public MHistoryEntity 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<MHistoryEntity> GetEnumerator()
                                        {
                                            MHistoryEnumerator _item = new MHistoryEnumerator(this);
                                            return _item;
                                        }

                                        IEnumerator IEnumerable.GetEnumerator()
                                        {
                                            MHistoryEnumerator _item = new MHistoryEnumerator(this);
                                            return _item;
                                        }
                                        #endregion
                                        
                                        public void SetDataByTable(DataTable _table)
                                        {
                                            _Collection.Clear();
                                            foreach (DataRow _row in _table.Rows)
                                            {
                                                MHistoryEntity _item = new MHistoryEntity();
                                                _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 MHistoryEntity[] FilterLastSelectByTableFilter(string _filter)
										{
											DataRow[] _rows = _LastSelectTable.Select(_filter);
											MHistoryEntity[] _results = new MHistoryEntity[_rows.Length];
											for (int i=0; i<_rows.Length; i++)
											{
												foreach(MHistoryEntity _item in _Collection)
												{
													if (_item.RowData == _rows[i])
													{
														_results[i] = _item;
														break;
													}
												}
											}
											return _results;
										}
										
                            
                                    }
                                }

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