如何更改 DataSet.xsd 中的连接字符串?

发布于 2024-08-21 17:45:26 字数 250 浏览 5 评论 0原文

我已经用 C# 构建了我的项目,我添加了 DataSet.xsd,并将其连接到

我计算机中的 Oracle DataBase - 工作非常好!

当我在客户计算机(连接到他的 Oracle 数据库)上安装时,

它崩溃了。

我需要更改 DataSet.xsd 文件上的连接字符串 - 但该怎么做?

有没有xml文件?还是配置文件?

提前致谢。

I have build my project in C#, I add DataSet.xsd, and connect him to

Oracle DataBase in my computer - work Excellent !!!!

When I installed on the customer computer (that connect to his Oracle DataBase) -

it crushed.

I need to change the connection string on the DataSet.xsd file - but how to do it ?

Is there any xml file ? Or configuration file ?

Thanks in advance.

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

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

发布评论

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

评论(9

反差帅 2024-08-28 17:45:26

您还可以打开数据集并选择要更新的TableAdapter,右键单击并转到属性。

在这里您将看到一个“连接”属性,您可以轻松更改 web.config 文件中的设置或输入新的连接详细信息。

You can also open the Dataset and select the TableAdapter that you want to update, right click and go to properties.

here you will see a "connection" property that you can easily change to settings in your web.config file or enter new connection details.

她说她爱他 2024-08-28 17:45:26

当使用向导生成数据集时,系统会要求您创建并存储连接字符串。查看您的 App.Config

When generating a DataSet with the Wizard you are asked to Create-and-Store a ConnectionString. Take a look in your App.Config

白日梦 2024-08-28 17:45:26

我也有类似的情况......我已经创建了很多数据集,它们每个都在后面的代码中记录了自己的连接字符串。 A 还通过我放置在 App.config 文件中的连接字符串手动与数据库交互。
因此,在部署到未知的服务器时更新所有这些将会很痛苦;但手动更改所有这些连接字符串也让我望而却步。
最后,我向 .xsd 设计页面添加了一个“测试”tableAdapter...并创建了一个新的连接字符串 - 这次指定将其放置在 App.config 文件中。然后神奇地...所有的 tableAdapter 现在都使用这个连接字符串 - 只需删除测试对象并删除它即可。瞧!

I had similar situation... I'd already created lots of datasets, and they each recorded their own connection string in the code behind. A also manually interacted with database via connectionstring I'd placed in App.config file.
So to update all this when deploying to as-yet-unknown server would be pain; yet manually changing all those connectionstrings also put me off.
In the end I added a 'test' tableAdapter to the .xsd design page... and created a New connection string - this time specifying it be placed in App.config file. Then by magic... all the tableAdapters now used this one connectionstring - just delete the test object & voila!

明天过后 2024-08-28 17:45:26

对于 WinForm 来说非常简单。请参考下图
输入图像描述这里

For WinForm its very simple. please refer below picture
enter image description here

有木有妳兜一样 2024-08-28 17:45:26

您可以像我的代码一样使用:
请注意,DataSet 可以通过 app.config 更改连接字符串,但您可以通过 TableAdapter 更改连接字符串,如下所示:

NCKHSV_TTD54TableAdapters.adtReportGiangVienTableAdapter tableAdapter = new 
NCKHSV_TTD54TableAdapters.adtReportGiangVienTableAdapter();//Create a TableAdapter to using.
 tableAdapter.Connection.ConnectionString = strConn;//change ConnectionString to strConn
 tableAdapter.ClearBeforeFill = true;
 tableAdapter.Fill(dataset.adtReportGiangVien);

You can using like my code:
Note that DataSet can change connection string by app.config but you can change connection string by TableAdapter like below:

NCKHSV_TTD54TableAdapters.adtReportGiangVienTableAdapter tableAdapter = new 
NCKHSV_TTD54TableAdapters.adtReportGiangVienTableAdapter();//Create a TableAdapter to using.
 tableAdapter.Connection.ConnectionString = strConn;//change ConnectionString to strConn
 tableAdapter.ClearBeforeFill = true;
 tableAdapter.Fill(dataset.adtReportGiangVien);
美人迟暮 2024-08-28 17:45:26

只需在应用程序启动时请求服务器凭据一次,或使用设置窗口并使用此方法:

从 SqlConnection 对象获取连接字符串或从单个数据形成连接字符串,然后执行以下操作:

[ApplicationNamespace].Properties.Settings.Default["ConnectionString"] = newconstr;

属于应用程序范围而不是用户范围的应用程序设置也可以设置。
但只能以编程方式,通过代码。它对我来说效果很好。希望它能帮助你!

Just request server credentials in your application startup once or use a settings window and use this method:

get the connection string from SqlConnection object or form the connection string from individual data and do it like this:

[ApplicationNamespace].Properties.Settings.Default["ConnectionString"] = newconstr;

The application settings that are Application and not user scope can be set too.
But only programatically, by code. It works fine for me. Hope it helps you out!

山有枢 2024-08-28 17:45:26

如果您的数据集已创建,请选择您选择显示的列下方的图标。它以 TableAdapter 结尾,转到属性。它显示当前的连接字符串,只需更改它即可。

喜欢这张图片

If your Dataset is created, select the icon below of the columns that you selected to show. It ends with TableAdapter, go to properties. it shows the current connection string, just change it.

Like this image

擦肩而过的背影 2024-08-28 17:45:26

我正在寻找全局更改 connectionsString 的方法,最后我找到了一种方法来做到这一点。
使用记事本程序打开 dataset.xsd,然后用新的连接字符串替换旧的连接字符串

<DbSource ConnectionRef="con_string_ar (Web.config)" DbObjectName="con_string_ar.dbo.albums" DbObjectType="Table"..>

I was searching about way to change the connectionsString globally, and finally I find a way to do that.
Open dataset.xsd using notepad program and then replace the old connectionstring with the new one

<DbSource ConnectionRef="con_string_ar (Web.config)" DbObjectName="con_string_ar.dbo.albums" DbObjectType="Table"..>
泅渡 2024-08-28 17:45:26

连接字符串有时存储在应用程序设置中(非 Web 项目:win 表单、库...)。右键单击您的项目>属性>设置。然后您可以更改连接字符串。

为了获得最佳结果,您可以首先打开文件 app.config (对于非 Web 项目)并修改连接字符串。之后,打开项目设置以“让 Visual Studio 发现连接字符串的更改并自动更新”。

The connection string is stored sometimes in application settings (non-web projects: win forms, libraries...). Right click your project > Properties > Settings. You can then change connection string.

For best results, you can first open file app.config (for non-web projects) and modify your connection string. After that, open project settings to "let visual studio discover changes to connection string and update it automatically".

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