?
Solved

SQLOLEDB Connection Error In Excel VBA Spreadsheet

Posted on 2011-09-20
4
Medium Priority
?
997 Views
Last Modified: 2012-05-12
Curious problem with an Excel spreadsheet which uses Excel VBA to connect to our SQL 2005 database.

EXCEL VBA CODE

szConnect = "Provider=SQLOLEDB;Data Source = " & g_strSQL_SERVER_IP & ";User ID = SQLDBUSER; password = sqldbuserpassword; Initial Catalog = DBNAME"

g_strUser = GetWindowsLogin

objConn.Open szConnect

-- calls a proc to validate the individual user's Windows login on a specific table
-- but we know these users DO exist on that specific DB table

sCommand = "exec sproc_CHECK_VALID_USER '" & g_strUser & "'"

MsgBox "DEBUG1: Issuing db call " & sCommand & " ........", vbOKOnly, "Debug Message"
Set rsData = objConn.Execute(sCommand)
MsgBox "DEBUG1: Back from db call " & sCommand & " ........", vbOKOnly, "Debug Message"
   
NOTES

Users in UK can use this spreadsheet and successfully see data from database, but we've been getting reports that users abroad (eg Dubai) have been getting the following Connection error when using the spreadsheet :

     [DBNETLIB][ConnectionOpen(Connect())]SQL Server does not exist or access denied

The database connection code in the Excel VBA code is the same for all users regardless of  their location.

The Excel VBA connects as SQL Server user 'SQLDBUSER' with password 'sqldbuserpassword' and we know these SQL login credentials are working OK.

We added various debug messages into the Excel VBA code g_strSQL_SERVER_IP correctly has the name of our SQL Server instance, and g_strUser correctly has the name of the user's Windows login.

For all our UK users, we see the DEBUG1 messages and they can access the spreadsheet without any problems. For our Dubai users, they do not even see the DEBUG1 messages but just get the [DBNETLIB] error shown above - so it looks as though for them the code fails on the
objConn.Open szConnect statement.

In SSMS, SQLOLEDB is listed as a Provider under Server Objects..Linked Servers..Providers.

What's got us stumped is that our UK users aren't having any problems, but our Dubai users are getting the error shown earlier - so would appreciate any help here, thanks ...
 
0
Comment
Question by:raymurphy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

by:raymurphy
ID: 36567917
Some additional info - we've established that the Dubai users are able to ping the SQL Server directly by issuing ping ServerName from a Windows command prompt (where ServerName contains the value held in the g_strSQL_SERVER_IP variable in the Excel VBA code.
0
 
LVL 16

Expert Comment

by:carsRST
ID: 36568329
As a test, Is it possible to see if someone in Dubai can connect to this SQL Server from Management Studio?

Could it be the users in Dubai do not have access/permission to the linked server sources?

Are the permissions for the UK users the same as they are in Dubai?
0
 
LVL 16

Accepted Solution

by:
carsRST earned 2000 total points
ID: 36568371
Check how the linked server connection is established.  Image below shows what that screen looks like.

My guess is that the Dubai user's basic security does not include access to the linked server source, where as the UK users do....this I assume since it sounds like you're using Windows authentication.

 oracle-linked-server-security-co.PNG
0
 

Author Comment

by:raymurphy
ID: 36569611
Thanks for the replies, carsRST ...

Unfortunately, the Dubai users do not have access to SSMS as they are just remote reporting users using Excel to get data from the database into this spreadsheet. We are not using Linked Servers as such, I only mentioned Linked Servers to show that the SQLOLEDB Provider existed on the server and was visible in SSMS.

The Excel db connection is made (for ALL users, ie UK users and Dubai users) via the SQL Server user 'SQLDBUSER' with password 'sqldbuserpassword' (rather than Windows authentication) and we know these SQL login credentials are working OK. Was wondering whether there might be a server-level configuration option which might be stopping the Dubai users connecting, or am I barking up the wrong tree ?

 
0

Featured Post

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question