Khai báo chuỗistring connectionString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
Nếu lỗi ConfigurationManager, bạn cần Add Reference vào Project. Bằng cách:
Trong App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="Conn" connectionString="Data Source=.;Initial Catalog=OmidPayamak;IntegratedSecurity=True" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
Nguồn bài viết:
DOTNET.VN