更改数据库名称 - 数据表适配器损坏

发布于 2024-10-05 09:20:23 字数 390 浏览 1 评论 0原文

我们最近更改了 Web 应用程序正在使用的 SQL 数据库的名称。现在,每个 DataTableAdapter 将更新为新的 ConnectionString。

我们的设置如下:

1)接口(网站项目)

2)业务逻辑(类库项目)

3)数据访问(类库项目)--->包含许多 DataSet 类

Data Access 项目的 app.config 包含唯一的连接字符串。创建每个 DataTableAdapter 时,向导会正确指向它。现在,我们必须更改 ConnectionString,并且所有现有的 DataTableAdapter(大约 60 个)都将无法工作。

仅仅改变 ConnectionString 是行不通的。我缺少什么?

谢谢

We've recently changed the name of the SQL DataBase our WebApp is using. Now, each of the DataTableAdapters will update to the new ConnectionString.

Our setup is as follows:

1) Interface (WebSite Project)

2) Business Logic (Class Library Project)

3) Data Access (Class Library Project) ---> Contains many DataSet classes

The app.config of the Data Access project contains the only connection string. When creating each of the DataTableAdapters, the wizard points to it correctly. Now, we've had to change the ConnectionString, and all of the existing DataTableAdapters (about ~60) will not work.

Simply changing the ConnectionString has not worked. What am I missing?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

樱&纷飞 2024-10-12 09:20:23

确保配置中的连接字符串名称与设置文件中的连接字符串名称相同。因为在生成的代码中,当它初始化连接字符串时,它设置连接字符串如下:

private void InitConnection() {
            this._connection = new global::System.Data.SqlClient.SqlConnection();
            this._connection.ConnectionString = global::ConsoleApplication4.Properties.Settings.Default.MyConnectionString;
        }

确保在您的应用程序配置中,连接字符串的名称相同。例如

<connectionStrings>
        <add name="ConsoleApplication4.Properties.Settings.MyConnectionString"
            connectionString="Data Source=MyServer;Initial Catalog=MyDB;Integrated Security=True"
            providerName="System.Data.SqlClient" />
</connectionStrings>

Make sure the connection string name in your config is the same as the one in the Settings File. Because in the generated code, when it initialzed the connectionstring it setting the connection string as follow :

private void InitConnection() {
            this._connection = new global::System.Data.SqlClient.SqlConnection();
            this._connection.ConnectionString = global::ConsoleApplication4.Properties.Settings.Default.MyConnectionString;
        }

Make sure that in your app config the name of your connectionString is the same. for example

<connectionStrings>
        <add name="ConsoleApplication4.Properties.Settings.MyConnectionString"
            connectionString="Data Source=MyServer;Initial Catalog=MyDB;Integrated Security=True"
            providerName="System.Data.SqlClient" />
</connectionStrings>
往日 2024-10-12 09:20:23

问题出在 Settings.Designer.cs 文件中。它是一个自动生成的文件,在正常更新/清理/构建过程后不会更新。

谢谢大家:-)

The problem was in the Settings.Designer.cs file. Its an auto-generated file that did not update after the normal updating/clean/build process.

Thanks Everyone :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文