如何在运行时将现有的强类型数据集连接到不同的服务器?
我正在 Visual C# 2008 中编写一个简单的太空帝国管理游戏,该游戏依赖于连接到远程 SQL Server 数据库来获取/存储数据。
我希望用户能够从登录屏幕连接到用户指定的 SQL 服务器(他指定 IP 地址、端口、数据库名称、ID、密码并按“连接”按钮)。但是,我发现数据集连接字符串属性是只读的,无法更改。有没有办法在运行时将向导生成的DataSet引导到用户指定的服务器?
I am coding a simple space empire management game in Visual C# 2008, which relies on connecting to a remote SQL server database to get/store data.
I would like the user to be able to connect to a user-specified SQL server from the login screen(he specifies IP address, port, database name, ID, password and presses "connect" button). However, I found out that the Dataset connection string property is read only and cannot be changed. Is there any way to guide the wizard-generated DataSet to a user-specified server at run time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信,如果您进入项目设置并将连接字符串设置类型从“连接字符串”更改为“字符串”并将范围从“应用程序”更改为“用户”,连接仍然有效,并且它成为可编辑的字符串运行时。
请在尝试此操作之前备份您的源代码。
I believe that if you go into the project settings and change the connection string setting type from "Connection String" to "string" and change the scope from "Application" to "User", the connection still works and it becomes an editable string at runtime.
Please back up your source code before trying this.