PageRenderTime 64ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/BaliEnterpriseSystems/BaliEnterpriseSystems/BestObjects/BestDatabase.cs

https://github.com/sirivedula/BEST
C# | 66 lines | 63 code | 3 blank | 0 comment | 6 complexity | d85fb7dfbb0b5d975f998cdd28226c7c MD5 | raw file
  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.HtmlControls;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Xml.Linq;
  12. using System.Data.OleDb;
  13. using System.Reflection;
  14. using System.ComponentModel;
  15. using BaliEnterpriseSystems.BestObjects;
  16. namespace BaliEnterpriseSystems.BestObjects
  17. {
  18. public class BestDatabase
  19. {
  20. public string dbConString
  21. {
  22. get
  23. {
  24. return ConfigurationSettings.AppSettings["dbConString"];
  25. }
  26. }
  27. private OleDbConnection _dbCon;
  28. public OleDbConnection dbCon
  29. {
  30. get
  31. {
  32. if (_dbCon == null)
  33. {
  34. OleDbConnectionStringBuilder consb = new OleDbConnectionStringBuilder(this.dbConString);
  35. if (HttpContext.Current.Session["CurrentUser"] == null)
  36. {
  37. consb.Add("Application Name", "NoBestLogin");
  38. }
  39. else
  40. {
  41. consb.Add("Application Name", Utils.User.UserName);
  42. }
  43. _dbCon = new OleDbConnection(consb.ToString());
  44. }
  45. return _dbCon;
  46. }
  47. }
  48. private OleDbCommand _dbCmd;
  49. public OleDbCommand dbCmd
  50. {
  51. get
  52. {
  53. if (this.dbCon.State != ConnectionState.Open)
  54. {
  55. this.dbCon.Open();
  56. }
  57. _dbCmd = new OleDbCommand();
  58. _dbCmd.Connection = this.dbCon;
  59. return _dbCmd;
  60. }
  61. }
  62. }
  63. }