简体   繁体   English

如何在运行时将现有的强类型数据集连接到其他服务器?

[英]How to connect an existing strongly-typed data set to a different server at run time?

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. 我正在用Visual C#2008编写一个简单的太空帝国管理游戏,该游戏依赖于连接到远程SQL Server数据库来获取/存储数据。

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). 我希望用户能够从登录屏幕连接到用户指定的SQL服务器(他指定IP地址,端口,数据库名称,ID,密码并按下“连接”按钮)。 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? 有什么方法可以在运行时将向导生成的数据集引导到用户指定的服务器?

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. 在尝试此操作之前,请备份您的源代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在服务器标签中使用强类型资源? - How can I use strongly-typed resources in server tags? 将强类型的数据传递给ViewMasterPage和ViewPage - Passing Strongly-Typed Data to a ViewMasterPage and ViewPage 如何使用强型卫星组件? - How to use strongly-typed satellite assembly? 如何将JObject复制到强类型对象中? - How to copy JObject into strongly-typed object? 我可以使用什么强类型数据结构来保存具有不同形状的多个RecordSet的集合 - What Strongly-Typed Data-Structure can I use to hold a collection of multiple RecordSets with different shape 使用ServiceStack.Redis,如何在事务中运行强类型的只读查询 - Using ServiceStack.Redis, how can I run strongly-typed read-only queries in a transaction 强类型数据集:添加数据后如何在db上保存数据? - Strongly-typed dataset: how to save data on db after adding data? 使用App.config设置强类型变量 - Using App.config to set strongly-typed variables NET Core 强类型数据源和 Visual Studio 中的设计器? - NET Core strongly-typed data sources and designer in Visual Studio? 强类型绑定源过滤器 - Strongly-Typed BindingSource Filter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM