Click here to Skip to main content
15,891,184 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.5K   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 MFoodEnumerator : IEnumerator<MFoodEntity>
                                    {
                                        MFoodEntityCollection _Item = null;
                                        int _position = -1;

                                        public MFoodEnumerator(MFoodEntityCollection _item)
                                        {
                                            _Item = _item;

                                        }

                                        public void Dispose()
                                        {
                                        }

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

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

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