in c# global connection to be used in all classes

后端 未结 5 1878
萌比男神i
萌比男神i 2021-01-22 18:59

I\'ve a connection string saved to Properties.Settings.Default, i need to use an sql connection in all classes without having to declare it everytime, so how should

5条回答
  •  旧时难觅i
    2021-01-22 19:21

    You can use this code for get coonection string

          var      defaultConn= new SqlConnection(ConfigurationManager.AppSettings["defaultConn"].ToString());
    

提交回复
热议问题