Esempio n. 1
0
        /// <summary>
        /// Khởi tạo SqlCommand
        /// </summary>
        /// <param name="procdureName">Tên Procedure cần dùng</param>
        /// <returns>SqlCommand</returns>
        /// <remarks></remarks>
        protected SqlCommand CreateSqlCommand(string procdureName = "", string commandText = "")
        {
            var sqlCommand = new SqlCommand();

            sqlCommand.Connection = ConnectSQL.GetConnection();
            if (string.IsNullOrEmpty(procdureName))
            {
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.CommandText = commandText;
            }
            else
            {
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = procdureName;
            }
            if (sqlCommand.Connection.State == ConnectionState.Closed)
            {
                sqlCommand.Connection.Open();
            }
            return(sqlCommand);
        }
Esempio n. 2
0
 /// <summary>
 /// Khởi tạo đối tượng Database để thao tác với dữ liệu
 /// </summary>
 /// <returns></returns>
 protected Database CreateDatabaseObject()
 {
     return(new SqlDatabase(ConnectSQL.GetConnectionString()));
 }