Jim Lahman's Blog

Fortitude|Endurance|Faith|Teamwork

  Home  |   Contact  |   Syndication    |   Login
  30 Posts | 0 Stories | 18 Comments | 0 Trackbacks

News

Archives

Links

Social

Sunday, November 06, 2011 #

Here is a technique to bind a List (of objects) to a DataGridView so that the public Properties appear as columns. 

BindArrayToGrid

 

In this example, the columns are binded to the individual public property of the object.  The column Random Number is binded to the public property RandomNumber while the column Square Root to the public property  SqRt

 

Create a class that contains the public properties that appear as columns in the dataGridView

 

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Text;
   5:   
   6:  namespace TestBindArrayToGrid
   7:  {
   8:      public class RandomNbr : System.Object
   9:      {
  10:          private Double m_RandomNbr = 0.0;
  11:          private Double m_SqRt = 0.0;
  12:   
  13:          private Random r;
  14:   
  15:          /* Each array list is a new object but we do not want to reseed the random number algorithm.  So
  16:           * we create this constructor to pass in the random number into the new object
  17:           */
  18:          public RandomNbr(Double RandomNbr)
  19:          {
  20:              m_RandomNbr = RandomNbr;
  21:              m_SqRt = Math.Sqrt(RandomNbr);
  22:          }
  23:   
  24:          /* This constructor generates the initial random number */
  25:          public RandomNbr()
  26:          {
  27:              m_RandomNbr = GenerateRandomNumber();
  28:              m_SqRt = Math.Sqrt(m_RandomNbr);
  29:          }
  30:   
  31:          /* This public property is binded to the Random Number column */
  32:          public Double RandomNumber  
  33:          {
  34:              get { return this.m_RandomNbr; }
  35:              set { m_RandomNbr = value; }
  36:          }
  37:   
  38:          /* This public property in binded to the Square Root column */
  39:          public Double SqRt
  40:          {
  41:              get { return this.m_SqRt; }
  42:              set { m_SqRt = value; }
  43:          }
  44:   
  45:          /* This seeds the random number algorithm */
  46:          private double GenerateRandomNumber()
  47:          {
  48:              TimeSpan ts = DateTime.Now.Subtract(new DateTime(2011,01,01));
  49:              var Seconds = ts.TotalSeconds;
  50:   
  51:              r = new Random((int) Seconds);
  52:              return r.NextDouble();
  53:          }
  54:   
  55:          /* Return the next random number as generated by the algorithm */
  56:          public Double GetNextRandom()
  57:          {
  58:              return r.NextDouble();
  59:          }
  60:   
  61:          /* For those cases when a random number and square root are to be returned. */
  62:          public void GetNextRandom(ref double _RandonNbr, ref double _SqRt)
  63:          {
  64:              _RandonNbr = m_RandomNbr = r.NextDouble();
  65:              _SqRt = m_SqRt = Math.Sqrt(m_RandomNbr);
  66:          }
  67:   
  68:      }
  69:  }

 

And here is the technique to bind the List<T> objects to the DataGridView

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.ComponentModel;
   4:  using System.Data;
   5:  using System.Drawing;
   6:  using System.Linq;
   7:  using System.Text;
   8:  using System.Windows.Forms;
   9:   
  10:  namespace TestBindArrayToGrid
  11:  {
  12:      public partial class frmBindArrayToGrid : Form
  13:      {
  14:          List<RandomNbr> lstRandom = new List<RandomNbr>();  // List<T>
  15:          private RandomNbr r = new RandomNbr();      // This seeds the random number generator
  16:   
  17:          public frmBindArrayToGrid()
  18:          {
  19:              InitializeComponent();
  20:          }
  21:   
  22:          private void cmdExit_Click(object sender, EventArgs e)
  23:          {
  24:              Application.Exit();
  25:          }
  26:   
  27:          private void frmBindArrayToGrid_FormLoad(object sender, EventArgs e)
  28:          {
  29:              GenerateRandomList();
  30:              BindArrayListToGrid();
  31:          }
  32:   
  33:          /* This binds each list object to the datagridview */
  34:          private void BindArrayListToGrid()
  35:          {
  36:              dgRandom.Columns.Clear();
  37:   
  38:              // Create new column for randon number
  39:              DataGridViewTextBoxColumn csRandom = new DataGridViewTextBoxColumn();
  40:              
  41:              csRandom.DataPropertyName = "RandomNumber";  // Public property name (as defined in the object)
  42:              csRandom.HeaderText = "Random Number";      // Header name
  43:              csRandom.DefaultCellStyle.Format = "#.#000";    // Format 
  44:              dgRandom.Columns.Add(csRandom);
  45:   
  46:              // Create new column for square root
  47:               DataGridViewTextBoxColumn csSqRt = new DataGridViewTextBoxColumn();
  48:   
  49:              csSqRt.DataPropertyName = "SqRt";  // Public property name (as defined in the object)
  50:              csSqRt.HeaderText = "Square Root";      // Header name
  51:              csSqRt.DefaultCellStyle.Format = "#.#000";    // Format 
  52:              dgRandom.Columns.Add(csSqRt);            
  53:   
  54:              dgRandom.DataSource = lstRandom;        // Binding is to the list of random numbers
  55:              /* Create the row headers */
  56:              int rowNumber = 1;
  57:              foreach (DataGridViewRow row in dgRandom.Rows)
  58:              {
  59:                  row.HeaderCell.Value = "R" + rowNumber;
  60:                  rowNumber++;
  61:              }
  62:              dgRandom.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
  63:   
  64:              dgRandom.Show();
  65:          }
  66:   
  67:          private void GenerateRandomList()
  68:          {
  69:              /* For each new list <object>, retrieve the next random number from the algorithm */
  70:              lstRandom.Add(new RandomNbr(r.GetNextRandom()));  
  71:              for (int i = 0; i < 100; i++)
  72:              {
  73:                  lstRandom.Add(new RandomNbr(r.GetNextRandom()));
  74:              }
  75:          }
  76:      }
  77:  }
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Tuesday, June 21, 2011 #

Goal: Since the system disk is a RAID 1 mirrored set, we can rebuild the shadow set by replacing one of the good sets with a blank disk

Steps

  • Shutdown and power down server
  • Remove the disk from bay 9, which is part of the system shadow set. Put this disk on the shelf

Empty RAID 1 bay 9

  • Insert blank/old disk into the empty bay

Label new disk before inserting into empty bay

 

 

Label the new disk before inserting it into the empty bay

 

 

 

  • Power up server
  • During the booting process, the following message appears: “Some configured disks have been removed from your system…”

Foreign configuration found - press 'C' to load config

 

 

 

Press ‘C’ to Load Configuration utility

 

 

 

 clip_image008

 

 

Press 'Y' to confirm to load the foreign configuration

 

 

 

  • In this example, the system shadow set is Disk Group 2.  (Before proceeding, confirm this is the disk group in your case).  Expanding the physical disks shows a disk in bay 8 and a missing disk in bay 9.  This is correct.   Now, we have to include the new inserted disk in this group

RAID controller reporting bay 9 is empty

 

 

 

RAID controller reporting bay 9 is empty

 

 

 

  • There may be times when the new disk is seen as a foreign disk.  In this case, do the following:

Foreign disk is reported in bay 9

 

 

Foreign disk is reported in bay 9

  • CTRL-N (Next Page) to Foreign Mgt
  • All the disk groups will be displayed.  Typically, the disk group containing the foreign disk will be grey. 
  • To remove the foreign disk
    • Highlight Controller
    • Press F2
    • Select Foreign
    • Select Clear (do NOT import the configuration!)

 Clear the foreign configuration

 

 

 

Clear the foreign configuration

  • Now the disk can be brought into the system shadow set disk group as a hot spare

 

  • To include the newly inserted disk into the system shadowset disk group, it must be brought in as a hot spare
    • Highlight Disk Group 2 (VD Management)
    • Hit F2
    • Select 'Manage Ded. HS'

Manage dedicated hot swap

 

 

Manage dedicated hot swap

      • Select the disk in bay 9 (Hit space bar to select)
      • Tab to 'OK'. 
      • Hit the return key

Select hot spare to bring into RAID 1 mirror set

 

 

Select hot spare to bring into RAID 1 mirror set

 

  • Rebuild automatically commences

Rebuild in process

 

 

Rebuild in process

 

Restart now or restart after rebuild is completed

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Monday, June 20, 2011 #

When restoring a database backup, by default, SQL Server places the database files in the master database file directory.  In this example, that location is in L:\MSSQL10.CHTL\MSSQL\DATA as shown by the issuance of sp_helpfile

Default_directory_location_of_master_database

 

Hence, the restored files for the database CHTL_L2_DB are in the same directory

 

Default_location_of_restored__SQL_Server_files_

 

Per SQL Server best practices, the log file should be on its own disk drive so that the database and log file can operate in a sequential manner and perform optimally.

The steps to move the log file is as follows:

  1. Record the location of the database files and the transaction log files
  2. Note the future destination of the transaction log file
  3. Get exclusive access to the database
  4. Detach from the database
  5. Move the log file to the new location
  6. Attach to the database
  7. Verify new location of transaction log

Record the location of the database file

To view the current location of the database files, use the system stored procedure, sp_helpfile

   1:  use chtl_l2_db
   2:  go
   3:   
   4:  sp_helpfile
   5:  go
sp_helpfile_output

 

Note the future destination of the transaction log file

The future destination of the transaction log file will be located in K:\MSSQLLog

Future_location_of_log_file

 

Get exclusive access to the database

To get exclusive access to the database, alter the database access to single_user.  If users are still connected to the database, remove them by using with rollback immediate option.  Note:  If you had a pane connected to the database when the it is placed into single_user mode, then you will be presented with a reconnection dialog box.

   1:  alter database chtl_l2_db
   2:  set single_user with rollback immediate
   3:  go

Detach from the database

 

Now detach from the database so that we can use windows explorer to move the transaction log file

   1:  use master
   2:  go
   3:   
   4:  sp_detach_db 'chtl_l2_db'
   5:  go

 

After copying the transaction log file

After_copying_the_trans_log_file

re-attach to the database

   1:  use master
   2:  go
   3:   
   4:  sp_attach_db 'chtl_l2_db',
   5:  'L:\MSSQL10.CHTL\MSSQL\DATA\CHTL_L2_DB.MDF',
   6:  'K:\MSSQLLog\CHTL_L2_DB_4.LDF',
   7:  'L:\MSSQL10.CHTL\MSSQL\DATA\CHTL_L2_DB_1.NDF',
   8:  'L:\MSSQL10.CHTL\MSSQL\DATA\CHTL_L2_DB_2.NDF',
   9:  'L:\MSSQL10.CHTL\MSSQL\DATA\CHTL_L2_DB_3.NDF'
  10:  GO
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

I scheduled a task to perform a windows backup of a single disk on the my server.  When I tested it, the task ran successfully – no problems, no errors; just as I expected. 

 

However, when the task ran as scheduled, it failed with error value 2147943645.  I wondered was this the answer to life, the universe and everything in it?  No.  That is 42. 

Task_failing_with_Error_value_2147943645

 

After doing some research and reviewing the task configuration, I realize that the task will only run if the user of logged on:

Cause_of_error_value_2147943645

 

So, this was the answer!!  I have to configure the task to run whether the user is logged or not.  Or, else I’ll get that nasty error value.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Friday, June 03, 2011 #

According the the Windows documentation, a backup of the system state can be created by using the command wbadmin start systemstatebackup.  In a cluster environment, this can only be performed on the secondary node, not the primary node.

Having a Windows 2008 failover cluster, this presents a conundrum in that I have services installed whose underlying executables are stored on the shareable SANS device.  This means that as the secondary node, the system state knows about the location of these files but cannot access these files. 

To get a list of services as recorded by the system state, I use the utility MSINFO32.EXE.  This is found by type MSINFO32 in the search box:

Searchiing_for_msinfo32

 

Using this utility, all the services are listed.  I highlight the ones that are installed from the SANS device.

List_of_services_whose_path_is_on_SANS_device

 

Performing a system state backup on this configuration appears to yield the Enumeration of the files failed error. 

system_state_backup_enumeration_error

It appears that performing a system state backup on this configuration is not possible.  The only manner in which I am able to capture the system state is by performing a full windows backup.

Does anyone have any suggestions on how to successfully perform a system state backup with this configuration?

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Rebuilding a windows cluster left behind some services I no longer needed.  These services are listed as part of the local services:

List_of_L2_Services

 

To uninstall these services, use the sc delete [servicename] command from the Administrator control prompt

uninstall_a_service

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Wednesday, May 04, 2011 #

On last evening’s walk with the hiking club (my first after the 40 miler) to stretch out the stiff muscles, I talked with a few members about Jean Henry, the 81-year old who completed the 20-, 26- and 40-mile hikes. 

And, everyone member said the same thing: “She has guts!”. 

I asked them to expound.  I was told that when most people reach their fifties, they come home from work, take it easy in front of the television and call it a night.  But, not Jean.  Rather, she put on her hiking clothes and hit the trail about every evening.  And, just not walking.  But, the bridle and hiking trails.

One member even said that Jean is his hero because of the example she has set for everyone else.

What kind of example are we setting for our children and the ones we love? 

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Monday, April 18, 2011 #

I've been hiking with the Cleveland Hiking Club.  And a lot. But, over the past month, I hiked a 15-miles, 20-miles and last Sunday, 26-miles (a Marathon!), 

As I hiked on these long miles, I had a lot of time to think and to think about my relationship with God.  I've been asking God for quite some time to help me develop a deeper relationship with Him.  Attending classes are good.  Attending service is good.  Being in communion with the community is good. But,  I was looking for something deeper.  Well, wouldn't you know He would use these long hikes to talk to me.  On the 20 miler I learned firsthand what Fortitude, Endurance, Faith and Teamwork means.  I learned what commitment means as I trained for these hikes.  These are also Christian principles and values.  You know, its one thing to sit in the classes and learn about these principles and values.  Its quite another to live them.

  • Fortitude - Courage in pain and adversity.  
  • Endurance - Power to endure an unpleasant or difficult situation without giving way
  • Faith - Belief in a higher a power and yourself; confidence to carry on
  • Teamwork - You can go farther as a group than by yourself.
  • Commitment - Dedicating oneself to complete a goal

I now understand more fully the race and commitment that is required by a Christian.

Phil 3:12-16:

12-14 I'm not saying that I have this all together, that I have it made. But I am well on my way, reaching out for Christ, who has so wondrously reached out for me. Friends, don't get me wrong: By no means do I count myself an expert in all of this, but I've got my eye on the goal, where God is beckoning us onward—to Jesus. I'm off and running, and I'm not turning back.
15-16 So let's keep focused on that goal, those of us who want everything God has for us. If any of you have something else in mind, something less than total commitment, God will clear your blurred vision—you'll see it yet! Now that we're on the right track, let's stay on it.

1 Cor 9:24-25:

24-25 You've all been to the stadium and seen the athletes race. Everyone runs; one wins. Run to win. All good athletes train hard. They do it for a gold medal that tarnishes and fades. You're after one that's gold eternally.

The marathon was something special.  There are so many parallels between a course of this kind and the Christian walk.  We started at 6:30am on Sunday at Shadow Lake Picnic Area in Solon.  It started off smooth and easy.  I even jogged part of it!  Rather than being with a group of people, this was done mostly on my own.  At the 7 mile mike, I hit construction and detour.  Oh my.  But, isn't our walk like this.  Things are going smooth and well, and then - wham - you hit road construction and a detour.  But, through preserving, one gets back one path.  At the 10 mile mark, after the construction and detour, was the first support station with juice, food and refreshments.  And, isn't God like this - after going through life's detour, He will provide a support station for you. 

And, I had 16 miles to go.   At the half way mark was another support station in Chagrin Falls.  And, God provides support stations along our personal walk so we can rest and freshen up so we can carry on with more vigor.

And, I needed that rest and freshening because I encountered hail at the Polo Fields.  And, this  was the most difficult part of the course because we had to hike the Buckeye Trail from the Polo Fields to Miles Road.  It was muddy, had two stream crossings and hilly.

There were a few sections of the trail that was not marked well. Which path do I take?  Which way do I go?  On the Buckeye Trail, I used my map and handy-dandy compass to figure out the route.  Another parallel to the Christian walk:

Ps 119:105:

Your word is a lamp to my feet and a light for my path.

And, at the end of this part of the marathon was yet another support station. 20 miles done, 6 to go.

Wouldn't you know it.  The support station was at the base of a 3 mile hill I had to hike up.   And, if you remember, Sunday was quite blustery. 

As I crested the hill, there were a group of people waiting for me, as this being my first marathon.  They wanted to make sure I finish so they hiked the remaining 3 miles with me.  23 miles done, 3 to go. And,isn't it like God to provide encouragement along our personal journey. 

As I crested the last hill, with the group with me, on top of the hill across the street, I looked up and there was the finish line with people cheering and clapping.  I completed the marathon.  I made it back home.  I finished the race.  There will be people cheering and clapping for us as we go home to Heaven. 

2 Tim 4:7-8:

7 I have fought the good fight, I have finished the race, I have kept the faith. 8Now there is in store for me the crown of righteousness, which the Lord, the righteous Judge, will award to me on that day—and not only to me, but also to all who have longed for his appearing.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Thursday, April 07, 2011 #

Fortitude: The courage to carry on against all odds.

Be that ice breaker; carry on until you reach your goal

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Hiking the 20 miler is not liking running in a race on a flat surface.  It includes hills, trails, uneven surfaces, climbing and ducking. 

This was my first attempt at this course.  I finished it in 6 hrs, 7 minutes, middle of the pack.  Not bad for my first time. 

There are four things I learned: Fortitude, Endurance, Faith and Teamwork

Fortitude – having the courage to finish in the face of odds. 

Endurance – having the strength to accomplish one’s goals.

Faith – believing in yourself.

Teamwork – you can go further by working with others.

ten down - ten to go

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati