Solved

SQLOLEDB Connection Error In Excel VBA Spreadsheet

Posted on 2011-09-20
4
962 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
  • 2
  • 2
4 Comments
 

Author Comment

by:raymurphy
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Suggested Solutions

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now