要确保BindingSource.DataSource从App.Config文件中获取连接信息,而不是硬编码的值,可以按照以下步骤进行操作:
<configuration>
<connectionStrings>
<add name="MyConnection" connectionString="Data Source=ServerName;Initial Catalog=DatabaseName;User ID=Username;Password=Password;" />
</connectionStrings>
</configuration>
string connectionString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
bindingSource.DataSource = connectionString;
这样,BindingSource.DataSource将从App.Config文件中获取连接信息,而不是硬编码的值。
推荐的腾讯云相关产品和产品介绍链接地址:
领取专属 10元无门槛券
手把手带您无忧上云