25 thg 6, 2019

WINDOWS FORMS: CHANGE CONNECTIONSTRING AT RUNTIME WITH APP.CONFIG IN C#


How to change ConnectionString dynamically in C#

Step 1Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "DynamicallyConnectionString" and then click OK
c# connection stringStep 2: Design your form as below
connection string in c#
Step 3: Add a connection string to the app.config file as below
1
2
3
4
5
<configuration>
  <connectionStrings>
    <add name="cn" connectionString="Data Source=.;Initial Catalog=Northwind;User ID=sa;Password=123@qaz?;" providerName="System.Data.SqlClient"/>
  </connectionStrings>
</configuration>

tham khảo tại đây.

WINDOWS FORMS: CHANGE CONNECTIONSTRING AT RUNTIME WITH APP.CONFIG IN C# Rating: 4.5 Diposkan Oleh: http://pdunoteit.blogspot.com/