ADODB仅本地可用:SQL Server远程连接报错求助
Troubleshooting the "SQL Server does not exist or access denied" Error
Hey there! Let's walk through the most likely fixes for this connection issue—since your code works locally but fails remotely, we can narrow down to server-side and network configs that often slip through the cracks.
Common Checks to Try
1. Verify SQL Server's Remote Connection Settings
- Open SQL Server Configuration Manager on your server. Navigate to SQL Server Network Configuration > Protocols for [Your Instance Name].
- Make sure the TCP/IP protocol is enabled (not just IP5—double-check all IP addresses listed under TCP/IP properties if needed).
- Go to the IP Addresses tab in TCP/IP properties, scroll down to the
IPAllsection:- Confirm the
TCP Portis set to your expected port (default is 1433; if you changed it, make sure your connection string matches). - Clear the
TCP Dynamic Portsfield—dynamic ports can prevent consistent remote connections.
- Confirm the
2. Confirm SQL Server is Listening on the Correct Port
- On the server, open Command Prompt and run:
(Replace 1433 with your custom port if applicable.)netstat -ano | findstr "1433" - Look for a line with
LISTENINGstatus. Cross-check the PID against thesqlservr.exeprocess in Task Manager > Services to ensure SQL Server is the one listening.
3. Double-Check Firewall Configurations
- You added an inbound rule, but verify these details:
- The rule targets the correct TCP port (1433 or your custom port).
- It applies to all relevant network profiles (Domain, Private, Public—adjust based on your environment).
- Don’t forget network-level firewalls: if your server is behind a company gateway or cloud provider security group, those also need to allow inbound traffic on the SQL port.
- Test port connectivity from your remote machine using:
If this fails, your firewall is still blocking the connection.telnet [ServerIP] 1433
4. Validate Your VBA Connection String
- Ensure the server address is formatted correctly: use
[ServerIP],[Port]if you’re not using the default 1433, or the server’s full hostname. - Confirm the authentication method matches your setup:
- For Windows Authentication: Make sure the remote user’s Windows account has SQL Server login access.
- For SQL Server Authentication: Verify the username/password are correct, and SQL Server is set to allow mixed mode authentication (check in SSMS > Server Properties > Security).
- Consider updating your ODBC driver in the connection string—old drivers can have compatibility issues with SQL Server 2014. Try using:
(Adjust for SQL auth if needed.)Driver={ODBC Driver 17 for SQL Server};Server=[YourServer];Database=[YourDB];Trusted_Connection=Yes;
5. Check SQL Server Login & Database Permissions
- Even if network access is allowed, the remote user needs:
- A valid login in SQL Server (under Security > Logins in SSMS).
- User mapping to your target database, with at least
db_datawriterpermission (to write data) anddb_datareader(to read, if needed).
6. Test Basic Network Connectivity
- First, ping the server IP from your remote machine to confirm it’s reachable. If ping fails, there’s a fundamental network issue (like incorrect IP, routing problems, or ICMP blocked by firewalls).
Start with the telnet/ping tests to rule out network/firewall issues first—those are the most common culprits. If those pass, dig into SQL Server settings and permissions. Let me know if any of these steps help you resolve the error!
内容的提问来源于stack exchange,提问作者user9394467
相关产品推荐
相关产品推荐

