SQL无法通过IP地址C#连接

发布于 2025-01-25 07:26:52 字数 276 浏览 3 评论 0原文

我想知道是否有人可以帮助我解决这个问题?即使我正确地为SQL Server的端口号和IP地址提供了我的IDE,我也无法连接到SQL Server。

 static SqlConnection connection = new SqlConnection(@"Data Source=192.168.1.198,49172;Initial Catalog=irradix_base;Integrated Security=False;User ID=sa;Password=pass;");

I was wondering if someone could help me with this problem I have? I am not able to connect to my SQL server even though I correctly provided my IDE with the SQL server's port number and my IP address.

 static SqlConnection connection = new SqlConnection(@"Data Source=192.168.1.198,49172;Initial Catalog=irradix_base;Integrated Security=False;User ID=sa;Password=pass;");

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

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

发布评论

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

评论(2

月隐月明月朦胧 2025-02-01 07:26:52

你能这样尝试吗
数据源= 192.168.1.198,49172;初始目录= EnverifyDB;用户ID = SA;密码= 123456

Can you try this way
Data Source=192.168.1.198,49172;Initial Catalog=EnVerifyDB;User ID=sa;Password=123456

春花秋月 2025-02-01 07:26:52

因此,事实证明,我从使用PowerShell命令查找听力端口,这是代码:

ForEach ($SQL_Proc in Get-Process | Select-Object -Property  ProcessName, Id | Where-Object {$_.ProcessName -like "*SQL*"})
{
    Get-NetTCPConnection | `
     Where-Object {$_.OwningProcess -eq $SQL_Proc.id} | `
      Select-Object -Property `
                                @{Label ="Process_Name" e={$SQL_Proc.ProcessName}}, `
                                @{Label ="Local_Address";e={$_.LocalAddress + ":" + $_.LocalPort }},  `
                                @{Label ="Remote_Address";e={$_.RemoteAddress + ":" + $_.RemotePort}}, State | `
      Format-Table
} 

So as it turns out, I found an answer from this post which uses a powershell command to find the listening port, here is the code:

ForEach ($SQL_Proc in Get-Process | Select-Object -Property  ProcessName, Id | Where-Object {$_.ProcessName -like "*SQL*"})
{
    Get-NetTCPConnection | `
     Where-Object {$_.OwningProcess -eq $SQL_Proc.id} | `
      Select-Object -Property `
                                @{Label ="Process_Name" e={$SQL_Proc.ProcessName}}, `
                                @{Label ="Local_Address";e={$_.LocalAddress + ":" + $_.LocalPort }},  `
                                @{Label ="Remote_Address";e={$_.RemoteAddress + ":" + $_.RemotePort}}, State | `
      Format-Table
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文