Click here to Skip to main content
15,885,767 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.Generic;
                                using System.Data;
                                using System.Linq;
                                using System.Text;
								using JohnKenedy.DataAccess;

                                namespace {0}
                                {
                                    public class {1}Entity
                                    {
                                        #region Properties
                                        private string _TableName = "{1}";
                                        private DataAccessTableFiller _Filler = null;
                                        public DataAccessTableFiller Filler
                                        {
                                            get
                                            {
                                                return _Filler;
                                            }
                                        }
                                        
                                        public DataRow RowData
                                        {
											get
											{
												if (Filler != null) return Filler.RowData;
												return null;
											}
                                        }
                                        #endregion

                                        public {1}Entity()
                                        {
                                            _Filler = DataAccessLayer.Manager[_TableName].GetFiller();
                                        }

                                        public void SetDataByDataRow(DataRow _row)
                                        {
                                            Filler.SetColumnValueByDataRow(_row);
                                        }
                                        
                                        public {1}Entity GetFullDataByUniqueRow()
                                        {
											{1}EntityCollection _collection = new {1}EntityCollection();
											IList<IDbDataParameter> _parameters = new List<IDbDataParameter>();
											
											string _sql = Filler.GetWhereFilterByAll(ref _parameters);
											_collection.GetDataByWhere(null, _sql, _parameters.ToArray<IDbDataParameter>(), null);
											
											if (_collection.Collection.Count <= 0) return null;
											return _collection[0];
                                        }
                                        
                                        public {1}Entity GetFullDataByPrimaryKey()
                                        {
											{1}EntityCollection _collection = new {1}EntityCollection();
											IDbDataParameter[] _parameters = null;
											
											string _sql = Filler.GetWhereFilterByPrimaryKey(ref _parameters);
											_collection.GetDataByWhere(null, _sql, _parameters, null);
											
											if (_collection.Collection.Count <= 0) return null;
											return _collection[0];
                                        }
                                        
                                        public long InsertIdentity()
                                        {
											{BeforeInsert}
                                            IDbCommand _com = Filler.GetInsertStatementFilterIdentity();
                                            long _result = DataAccessLayer.Manager[_TableName].ExecuteNonQueryInsertIdentityValueFromCommand(_Filler);
                                            return _result;
                                        }

                                        public int Insert()
                                        {
											{BeforeInsert}
                                            IDbCommand _com = Filler.GetInsertStatementNoFilter();
                                            int _result = DataAccessLayer.Manager[_TableName].ExecuteNonQueryInsertFromCommand(_Filler);
                                            return _result;
                                        }

                                        public int Delete()
                                        {
                                            IDbCommand _com = Filler.GetDeleteStatementForAllFilter();
                                            int _result = DataAccessLayer.Manager[_TableName].ExecuteNonQueryDeleteFromCommand(_Filler);
                                            return _result;
                                        }

                                        public int DeletePrimaryKey()
                                        {
                                            IDbCommand _com = Filler.GetDeleteStatementForPrimaryKey();
                                            int _result = DataAccessLayer.Manager[_TableName].ExecuteNonQueryDeleteFromCommand(_Filler);
                                            return _result;
                                        }
                                        
                                        public int DeleteByWhere(string _sql, IDbDataParameter[] _parameters)
										{
											return DataAccessLayer.Manager[_TableName].ExecuteNonQueryDeleteFromWhere(_sql, _parameters);
										}

                                        public int Update()
                                        {
											{BeforeUpdate}
                                            IDbCommand _com = Filler.GetUpdateStatementFilterIdentity();
                                            int _result = DataAccessLayer.Manager[_TableName].ExecuteNonQueryUpdateFromCommand(_Filler);
                                            return _result;
                                        }
                                        

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