Click here to Skip to main content
15,909,445 members
Home / Discussions / C#
   

C#

 
QuestionStackTrace Pin
Jassim Rahma25-Nov-10 1:38
Jassim Rahma25-Nov-10 1:38 
AnswerRe: StackTrace Pin
Luc Pattyn25-Nov-10 1:46
sitebuilderLuc Pattyn25-Nov-10 1:46 
AnswerRe: StackTrace Pin
Keith Barrow25-Nov-10 1:48
professionalKeith Barrow25-Nov-10 1:48 
AnswerRe: StackTrace Pin
Pete O'Hanlon25-Nov-10 2:06
mvePete O'Hanlon25-Nov-10 2:06 
GeneralRe: StackTrace Pin
Bernhard Hiller25-Nov-10 23:47
Bernhard Hiller25-Nov-10 23:47 
QuestionHashTable or App.Config from db Pin
Jassim Rahma25-Nov-10 1:22
Jassim Rahma25-Nov-10 1:22 
AnswerRe: HashTable or App.Config from db Pin
Manfred Rudolf Bihy25-Nov-10 1:46
professionalManfred Rudolf Bihy25-Nov-10 1:46 
GeneralRe: HashTable or App.Config from db Pin
Jassim Rahma28-Nov-10 3:04
Jassim Rahma28-Nov-10 3:04 
this is what I am currently doing... what do you think?

public void get_system_properties()
{
    try
    {
        _system_parameters_hash = new Hashtable();

        _system_parameters_hash.Add("SQL_SERVER_CONNECTION", null);
        _system_parameters_hash.Add("SQL_SERVER_DATABASE", "Cure");
        _system_parameters_hash.Add("EVENT_LOG_DESCRIPTION", null);
        _system_parameters_hash.Add("SYSTEM_LOG_FOLDER", null);

        _system_parameters_hash["SYSTEM_LOG_FOLDER"] = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\" + Application.ProductName + @"\";


        _system_parameters_hash["SQL_SERVER_CONNECTION"] = "Data Source=";
        _system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLServer").ToString();
        _system_parameters_hash["SQL_SERVER_CONNECTION"] += ";initial catalog=";
        _system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLDatabase").ToString();
        _system_parameters_hash["SQL_SERVER_CONNECTION"] += ";User Id=";
        _system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLUser").ToString();
        _system_parameters_hash["SQL_SERVER_CONNECTION"] += ";Password=";
        _system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLPassword").ToString();
        _system_parameters_hash["SQL_SERVER_CONNECTION"] += ";Connection Timeout=";
        _system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLTimeout").ToString();

        sql_connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["SQLdb"].ConnectionString);
        sql_connection.Open();
        sql_command = new MySqlCommand("sp_get_system_parameters", sql_connection);
        sql_command.CommandType = CommandType.StoredProcedure;
        sql_reader = sql_command.ExecuteReader();

        while (sql_reader.Read())
        {
            if (_system_parameters_hash.ContainsKey(sql_reader["system_param_name"])) return;

            if (sql_reader["system_param_value"] == DBNull.Value)
            {
                _system_parameters_hash.Add(sql_reader["system_param_name"].ToString(), null);
            }
            else
            {
                // MessageBox.Show("Name: " + sql_reader["system_param_name"].ToString() + " - value: " + sql_reader["system_param_value"].ToString());

                if ((string)sql_reader["system_param_type"] == "bit") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToBoolean(sql_reader["system_param_value"]));
                else if ((string)sql_reader["system_param_type"] == "string") _system_parameters_hash.Add((string)sql_reader["system_param_name"], (string)sql_reader["system_param_value"]);
                else if ((string)sql_reader["system_param_type"] == "int") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToInt32(sql_reader["system_param_value"]));
                else if ((string)sql_reader["system_param_type"] == "int64") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToInt64(sql_reader["system_param_value"]));
                else if ((string)sql_reader["system_param_type"] == "short") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToInt16(sql_reader["system_param_value"]));
            }                    
        }
    }
    catch (Exception exp)
    {
        write_log("System", null, null, "Error populating system properties!!", exp);
        MessageBox.Show("Error populating system properties!!" + Environment.NewLine + "Please contact your system administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        Application.Exit();
    }
    finally
    {
        if (sql_reader != null) sql_reader.Close();
        if (sql_connection != null)
        {
            if (sql_connection.State == ConnectionState.Open)
                sql_connection.Close();
        }
    }

AnswerRe: HashTable or App.Config from db Pin
PIEBALDconsult25-Nov-10 2:59
mvePIEBALDconsult25-Nov-10 2:59 
QuestionProgress bar Pin
pancakeleh24-Nov-10 22:51
pancakeleh24-Nov-10 22:51 
AnswerRe: Progress bar Pin
JF201524-Nov-10 23:06
JF201524-Nov-10 23:06 
AnswerRe: Progress bar Pin
#realJSOP24-Nov-10 23:57
professional#realJSOP24-Nov-10 23:57 
AnswerRe: Progress bar Pin
Luc Pattyn25-Nov-10 1:43
sitebuilderLuc Pattyn25-Nov-10 1:43 
AnswerRe: Progress bar Pin
PIEBALDconsult25-Nov-10 3:36
mvePIEBALDconsult25-Nov-10 3:36 
AnswerRe: Progress bar Pin
_Erik_25-Nov-10 4:58
_Erik_25-Nov-10 4:58 
QuestionHelp converting java-script to C#. Pin
E3pO24-Nov-10 21:35
E3pO24-Nov-10 21:35 
AnswerRe: Help converting java-script to C#. Pin
AhsanS24-Nov-10 22:58
AhsanS24-Nov-10 22:58 
GeneralRe: Help converting java-script to C#. Pin
E3pO25-Nov-10 14:23
E3pO25-Nov-10 14:23 
AnswerRe: Help converting java-script to C#. Pin
E3pO25-Nov-10 17:00
E3pO25-Nov-10 17:00 
QuestionHow to add Horizontal Scrollbar to Listbox in Smart Device Application (C#) Pin
pchze24-Nov-10 21:07
pchze24-Nov-10 21:07 
AnswerRe: How to add Horizontal Scrollbar to Listbox in Smart Device Application (C#) Pin
OriginalGriff24-Nov-10 21:48
mveOriginalGriff24-Nov-10 21:48 
GeneralRe: How to add Horizontal Scrollbar to Listbox in Smart Device Application (C#) Pin
pchze24-Nov-10 21:52
pchze24-Nov-10 21:52 
GeneralRe: How to add Horizontal Scrollbar to Listbox in Smart Device Application (C#) Pin
Richard MacCutchan24-Nov-10 22:45
mveRichard MacCutchan24-Nov-10 22:45 
QuestionSelection of the list view element in large icon mode problem. Pin
Chesnokov Yuriy24-Nov-10 20:59
professionalChesnokov Yuriy24-Nov-10 20:59 
AnswerRe: Selection of the list view element in large icon mode problem. Pin
Luc Pattyn25-Nov-10 3:03
sitebuilderLuc Pattyn25-Nov-10 3:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.