ConnectorManager.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using HNWD.Pregrant.Common;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. namespace HNWD.Pregrant.DataAccess
  5. {
  6. public class ConnectorManager
  7. {
  8. //private readonly static DbConnection connection = new OleDbConnection(GlobalConfigureSetting.GetConfigureSetting("WD_IPCALL_PREGNANT"));
  9. //private readonly static object lockobj = new object();
  10. //public static DbConnection GetDbInstance()
  11. //{
  12. // lock (lockobj)
  13. // {
  14. // if (connection.State == ConnectionState.Closed)
  15. // {
  16. // connection.Open();
  17. // }
  18. // }
  19. // return connection;
  20. //}
  21. //public void Close()
  22. //{
  23. // if (connection.State == ConnectionState.Open)
  24. // {
  25. // connection.Close();
  26. // }
  27. //}
  28. private readonly static string connStr = GlobalConfigureSetting.GetConfigureSetting("WD_IPCALL_PREGNANT");
  29. public SqlConnection GetInstance()
  30. {
  31. SqlConnection conn = new SqlConnection(connStr);
  32. if (conn.State == ConnectionState.Closed)
  33. {
  34. conn.Open();
  35. }
  36. return conn;
  37. }
  38. }
  39. }