且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用C#创建客户端服务器应用程序

更新时间:2023-11-14 11:22:46

好的,所以你的连接字符串需要在代码中修改。这是简单的字符串操作。



最简单的方法是用IP地址或主机名替换字符串中的标签:

OK, so your connection string needs to be modified in code. That's simple string manipulation.

The easiest way to do it is to just replace a tag in the string with the IP address or host name:
    Server={SERVER};Database=myDataBase;User Id=myUsername;
Password=myPassword;




string ipAddress = "192.168.0.1";   // or a resolvable host name
string connString = templateConnString.Replace("{SERVER}", ipAddress);