Step 1:
Right Click on project->Add->New Item->General
Select “Application Configuration File” and click on “Add”
Step 2:
Add bellow section in config file and change DatabaseName,Database,Username,Password according to connect server
Step 3:
Add reference of System.Configuration.
Step 4:
Add bellow code where you want to use connection string
Right Click on project->Add->New Item->General
Select “Application Configuration File” and click on “Add”
Step 2:
Add bellow section in config file and change DatabaseName,Database,Username,Password according to connect server
</configuration> <appSettings> <add key="ConnectionString" value="Data Source=Persist Security Info=True;Initial Catalog=DatabaseName;Data Source=DatabasePath;User ID=UserName;Password=Password" /> </appSettings> </configuration>
Step 3:
Add reference of System.Configuration.
Step 4:
Add bellow code where you want to use connection string
Configuration.ConfigurationManager.AppSettings("ConnectionString").ToString()
0 comments:
Post a Comment