Here's what I did... after Rob's help and many fun and four letter adjectives, I rebuilt the SQL table to have varchar and INT values for storage. I added the "idle time" to the database as integer 40.
I wrote a new method making it private and keeping the code local. Before, I was trying to create it public, pass it all around, and I was making a mess. I also didn't realize that the code used call the idle time was being called from several places, so I cleaned that up as well.
private static int getIdleTime()
{
string conString = MgmtSystem.Properties.Settings.Default.ConnString;
int idleTime = 0;
string sql = MgmtSystem.Properties.Settings.Default.SqlGetConfIdleTime;
using ( SqlConnection conn = new SqlConnection( conString ) )
{
SqlCommand cmd = new SqlCommand( sql, conn );
try
{
conn.Open();
idleTime = ( int )cmd.ExecuteScalar();
}
catch ( SqlException ex )
{
MessageBox.Show( ex.ToString() );
log.Debug( "SQL Exception in Main Desktop under getIdleTime(): " + ex );
}
}
return ( int )idleTime;
}
Took that new value of idleTime and sent it a "string'n" :)
set var = idleTime
string finalVar so it looked like the parsed time span values it so desperately needed: "00:40:00"
and passed it into the time span parse
int var = getIdleTime();
string finalVar = "00:" + var + ":00";
applicationIdle.IdleTime = System.TimeSpan.Parse( finalVar );
Now everything is perfect. On main form load, the timer counts down, alerts the user they've been idle for "X" minutes, and then logs them out when they fail to comply.
BTW - Rob, I know the catch doesn't return a value, only a SQL exception. That's what I want. If the value is not set in the database, then I don't want the user to continue. It is an industry wide regulation that all PHI products have an idle time.