在混乱的网络上指定 SQL Server 连接字符串

发布于 2024-12-07 08:26:38 字数 828 浏览 0 评论 0原文

在我开始提出问题之前,当前的情况是

  1. C# Winforms 应用程序需要部署在我们的LAN上。

  2. 网络包含 200 多台运行 Windows XP(及以上)的计算机,且具有相同的域/工作组。

  3. 不幸的是,整个网络中仍然存在一些混淆和 IP 冲突

  4. 网络仍然有效!!...(咳咳..)

  5. < p>中央服务器(具有唯一的名称和 IP)托管数据库 (SQL Server 2008 R2)

  6. 应用程序具有指定客户端计算机上的连接字符串的规定

  7. 应用程序验证此字符串(打开>关闭连接,否则异常)并存储在本地文件中。

现在,我的问题是...

应用程序在检查阶段成功连接到服务器(打开>关闭连接),但在从服务器获取实际数据集时失败

  • 在这个混合场景中,哪种在连接字符串中寻址服务器的最可靠方法

即使我使用“sa”帐户,这也是如此,我已使用计算机名称/IP来寻址服务器

The current scenario before i start asking my question

  1. A C# Winforms application needs to be deployed on our LAN.

  2. The network contains 200+ computers running Windows XP (& above) having the same domain/workgroup.

  3. Unfortunately, there's still some mixups and IP conflicts throughout the network.

  4. The network still works !!... (ahem..)

  5. A central server (with unique name & IP) hosts the database (SQL Server 2008 R2)

  6. The application has a provision to specify the connectionstring on the client machine

  7. The application validates this string (open > close connection else exception) and stores in a local file.

Now, My problem is that...

The application connects successfully to the server (open > close connection) during the checking phase, but fails when there's actual datasets are to be fetched from the server.

  • Which is the most reliable way to address the server in the connection string in this mixed up scene ?

This holds true even if i use the "sa" account, i have used machine name / IP to address the server

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

留一抹残留的笑 2024-12-14 08:26:38

当您说您的应用程序“在获取实际数据集时失败”时,您的意思是什么?有什么错误?将您的 SqlDataAdapter.Fill() 方法封装在 try catch 块中,并将该错误输出到日志或 GUI 中以进行快速调试。错误说明了什么?这是网络或实例相关的问题吗?

应用程序成功连接到服务器
您是在谈论作为物理机器的服务器,还是在谈论容纳您尝试连接的数据库的 SQL Server 实例?

这是一个很大的“陷阱”。如果您使用命名实例,则需要确保 SQL Server Browser 服务正在容纳 SQL Server 实例的服务器上运行。该服务在通过端口 1434 进行访问时,会告诉应用程序命名实例正在侦听哪个动态端口。

此外,您的连接字符串可能存在一些问题。

长话短说,几乎不可能用很少的给定信息来判断你的问题是什么。这里只是猜测故障排除。请给我更多信息。

编辑:如果您的网络上有 DHCP/DNS 服务器,那么我不明白为什么您会遇到“混乱”的工作站网络问题,至少在 IP 分配和名称解析方面是如此。您的工作站需要能够解析服务器名称才能访问它。但这听起来不像是你的问题。

When you say your application "fails when there's actual datasets are to be fetched", what do you mean? What's the error? Encapsulate your SqlDataAdapter.Fill() method in a try catch block and out that error to a log or the GUI for quick debugging purposes. What does the error say? Is it a network or instance related issue..?

The application connects successfully to the server
Are you talking about the server as a physical machine, or are you talking about the SQL Server instance that houses the database you are trying to connect to?

Here's a big "gotcha". If you are using a named instance, then you need to make sure that the SQL Server Browser service is running on the server that houses the SQL Server instance(s). That is the service that, when reached out over port 1434, tells the application what dynamic port the named instance is listening to.

Also, your connection string could have some issues in it.

Long story short, it is almost impossible to tell what your problem is with the very little given information. It is all just guessing troubleshooting here. Please give me more information.

Edit: if you have a DHCP/DNS server on your network, then I don't see why you should be getting "messed up" workstation network issues, at least with IP assigning and name resolution. Your workstations need to be able to resolve the server name to reach it. But it doesn't sound like that's your issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文