Accessing database connection string using app.config in C# winform

前端 未结 10 1167
遇见更好的自我
遇见更好的自我 2020-12-06 00:27

I can\'t seem to be able to access the app.config database connection string in my c# winforms app.

app.config code

   
           


        
10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-06 00:39

    About this:

    I get an error: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

    I just declared a var like this and solved the problem:

    var strConnection = System.Configuration.ConfigurationManager.ConnectionStrings["MyDBConnectionString"].ConnectionString;
    

提交回复
热议问题