gpt4 book ai didi

c# - DataSource C# 中使用的变量

转载 作者:行者123 更新时间:2023-11-30 14:40:21 24 4
gpt4 key购买 nike

我有以下代码,但它似乎无法连接,只是想知道我是否引用了错误的变量?

sqlConnectionNW.ConnectionString = "Data Source=@server;Initial Catalog=Northwind;Integrated Security=True";

当我将其更改为:

sqlConnectionNW.ConnectionString = "Data Source=ISSP\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True";

它工作正常。只是当我将其更改为变量“服务器”时。

最佳答案

更像是这样:

string mySQLServer = "ISSP\SQLEXPRESS";

sqlConnectionNW.ConnectionSTring = "Data Source=" + mySQLServer + ";Initial Catalog=Northwind;Integrated Security=True";

关于c# - DataSource C# 中使用的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5418973/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com