PageRenderTime 149ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/GPX.Server.Extension/GeoRSSClient/ConnectionManager.cs

https://bitbucket.org/shope/dfu
C# | 56 lines | 48 code | 8 blank | 0 comment | 0 complexity | 9aaba3993b08d9dd333a498bb5bd508b MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data.SqlClient;
  6. using System.Configuration;
  7. using System.Data;
  8. namespace GeoRSSClient
  9. {
  10. static class ConnectionManager
  11. {
  12. public static SqlConnection GetConnection(string connectionName)
  13. {
  14. try
  15. {
  16. string connectionString = ConfigurationManager.ConnectionStrings[connectionName].ConnectionString;
  17. return new SqlConnection(connectionString);
  18. }
  19. catch(Exception ex)
  20. {
  21. throw ex;
  22. }
  23. finally
  24. {
  25. }
  26. }
  27. public static DataTable RunQuery(SqlConnection connection, string sql)
  28. {
  29. try
  30. {
  31. connection.Open();
  32. SqlCommand brokerCommand = new SqlCommand(sql, connection);
  33. SqlDataAdapter brokerAdapter = new SqlDataAdapter();
  34. DataSet ds = new DataSet();
  35. brokerAdapter.SelectCommand = brokerCommand;
  36. brokerAdapter.Fill(ds);
  37. return ds.Tables[0];
  38. }
  39. catch (Exception ex)
  40. {
  41. throw ex;
  42. }
  43. finally
  44. {
  45. }
  46. }
  47. }
  48. }