Return to Snippet

Revision: 2924
at May 9, 2007 15:24 by lfbarbieri


Initial Code
try
        {
            // Create and open a connection object
            conn = new SqlConnection(configurationConnString);
            conn.Open();

            // Set Stored Proc 
            SqlCommand cmd = new SqlCommand("spGetConfigSettingsByApplication", conn);
            cmd.CommandType = CommandType.StoredProcedure;

            // Set Parameters
            cmd.Parameters.Add(new SqlParameter("@applicationName", SqlDbType.NVarChar, 50));
            cmd.Parameters["@applicationName"].Value = "FTU";

            // execute the command
            rdr = cmd.ExecuteReader();

            // iterate through results, printing each to console
            while (rdr.Read())
            {
                configSettings.Add(rdr["AppKey"], rdr["AppValue"]);
            }
        }
        finally
        {
            if (conn != null) conn.Close();
            if (rdr != null) rdr.Close();
        }

Initial URL

                                

Initial Description

                                

Initial Title
Database Retrieve

Initial Tags
database, sql

Initial Language
C#