Database Retrieve


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. try
  2. {
  3. // Create and open a connection object
  4. conn = new SqlConnection(configurationConnString);
  5. conn.Open();
  6.  
  7. // Set Stored Proc
  8. SqlCommand cmd = new SqlCommand("spGetConfigSettingsByApplication", conn);
  9. cmd.CommandType = CommandType.StoredProcedure;
  10.  
  11. // Set Parameters
  12. cmd.Parameters.Add(new SqlParameter("@applicationName", SqlDbType.NVarChar, 50));
  13. cmd.Parameters["@applicationName"].Value = "FTU";
  14.  
  15. // execute the command
  16. rdr = cmd.ExecuteReader();
  17.  
  18. // iterate through results, printing each to console
  19. while (rdr.Read())
  20. {
  21. configSettings.Add(rdr["AppKey"], rdr["AppValue"]);
  22. }
  23. }
  24. finally
  25. {
  26. if (conn != null) conn.Close();
  27. if (rdr != null) rdr.Close();
  28. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.