Goran Bibic

Goran Bibic

  • 452
  • 2.9k
  • 181.1k

multiple mssql connection string in class c#

Jul 25 2019 3:43 AM
multiple mssql connection string in class c#
 
Need for my app
Have database  2017,2018,2019...I add IN every form connection string
 
  1. string BSS_2017 = Properties.Settings.Default.MG_SISTEM_2017CS;     string BSS_2018 = Properties.Settings.Default.MG_SISTEM_2018CS;  
  2. string BSS_2019 = Properties.Settings.Default.MG_SISTEM_2019CS; 
  3. string con; 
 Then in label chek value (2017,2018 or2019)
 
  1. public popis()  
  2.         {  
  3.             InitializeComponent();  
  4.             yearlabel.Text = getYear();  
  5.         } 
 And connect
 
  1. private String getGodina()  
  2.        {  
  3.   
  4.            string value = login.godina.ToString();  
  5.   
  6.            return value;  
  7.        }  
  8.   
  9.   
  10.        public void PullData()  
  11.        {  
  12.            if (yearlabel.Text == "2017")  
  13.            {  
  14.                con = BSS_2019;  
  15.            }  
  16.            else if (yearlabel.Text == "2018")  
  17.            {  
  18.                con = BSS_2018;  
  19.            }  
  20.   
  21.            else if (yearlabel.Text == "2019")  
  22.            {  
  23.               con = BSS_2019;  
  24.            }  
  25.   
  26.        } 
 
 
That work fine...but...I must put this in every form in my app....need help
To create some class with this value.
Help?
 

Answers (7)