简体   繁体   中英

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.

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM