1
Answer

RE: application scope variables ... cant access tthem...

john_farrellus

john_farrellus

21y
2.9k
1
Thread locked, for some reason (maybe a good reason). Create a class, and set some properties, or make the member variables public if you like... If you make the constructor static, you can fetch the values from the database for config file. Here is my solution to using Global variables in C#: public class SystemProfile { #region Member Variables private static string mstrCurrentLanguage; private static string mstrCurrentCulture; private static bool mblnUseMetricUnits; private static bool mblnRequireRace; private static bool mblnShowBMI; private static Guid mBMIProtocol; #endregion #region Constructor /// /// Static, so it will force a load of the settings the first time they are requested. /// static SystemProfile() { LoadSettings(); } #endregion #region Public/Private Static Methods /// /// Will re-load the settings, used after they are changed. /// public static void ReFresh() { LoadSettings(); } private static void LoadSettings() { Polar.Electro.US.TriFIT.Data.SystemProfile dataSystemProfile = new Polar.Electro.US.TriFIT.Data.SystemProfile(); xsdSystemProfile xsdProfile = dataSystemProfile.Load(); mstrCurrentLanguage = xsdProfile.SystemProfile[0].CurrentLanguage; mstrCurrentCulture = xsdProfile.SystemProfile[0].CurrentCulture; mblnUseMetricUnits = xsdProfile.SystemProfile[0].UseMetricUnits; mblnRequireRace = xsdProfile.SystemProfile[0].RequireRace; mblnShowBMI = xsdProfile.SystemProfile[0].ShowBMI; mBMIProtocol = new Guid(xsdProfile.SystemProfile[0].BMIProtocol); xsdProfile.Dispose(); dataSystemProfile.Dispose(); } #endregion #region Public Static Properties /// /// Returns the current language the program is using. /// public static string CurrentLanguage { get { return mstrCurrentLanguage; } } /// /// Returns the culture settings the program is using. /// public static string CurrentCulture { get { return mstrCurrentCulture; } } /// /// Metric flag. /// public static bool UseMetricUnits { get { return mblnUseMetricUnits; } } /// /// Race flag. /// public static bool RequireRace { get { return mblnRequireRace; } } /// /// BMI Flag. /// public static bool ShowBMI { get { return mblnShowBMI; } } /// /// BMI Protocol. /// public static Guid BMIProtocol { get { return mBMIProtocol; } } #endregion }
Answers (1)
1
Ben Chris
35 5.5k 1.1m 8y
your issue here is that you are comparing dates valus exactly with the designated columns and I am assuming that your table date column is of datetime type. This means you need to discard time part from both your target column and your from and to dates i.e.
 
 
  1. select * from tablename where DATEADD(dd,0,DATEDIFF(dd,0,date )) between DATEADD(dd,0,DATEDIFF(dd,0,'01-12-2016')) AND DATEADD(dd,0,DATEDIFF(dd,0,'01-02-2017')) 
Accepted
1
Rajeev Punhani
NA 4.7k 402.7k 8y

Hi Vinay,

 Please find the below link.

https://www.codeproject.com/tips/355235/how-to-search-between-two-dates-and-get-all-record 
1
Amit Gupta
NA 16.5k 25.7k 8y
@Vinay
 
It has always been observed for many times that the problem is occuring with only the date formats
 
Always use the universal format 'yyyy-MM-dd' format instead using 'MM-dd-yyyy'. You can change its format whichever suits the clients.
 
try searching like this
 select * from tablename where date between '2016-12-01' and '2017-02-01'
 
1
Catcher Wong
NA 4.5k 188.6k 8y
Hi , 
 
I can not  understand you question clearly ! Do you mean that?
 
1
Ramesh Palanivel
NA 9.5k 138.6k 8y
HI Vinay,
 
Try your code first in your DB, if it is working fine , check whether the DB and system format both are same or not.
 
try this URL, It may help you
 
http://stackoverflow.com/questions/14353434/selecting-data-between-2-dates 
 
http://stackoverflow.com/questions/16447877/c-sharp-between-two-dates-search
 
http://stackoverflow.com/questions/35272405/how-to-search-between-two-dates-in-c-sharp-with-ms-access
 
http://www.c-sharpcorner.com/forums/search-between-two-dates