Solved

SQLOLEDB Connection Error In Excel VBA Spreadsheet

Posted on 2011-09-20
4
975 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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ms sql + top 1 for each customer 3 63
Delete from table 6 48
How to use TOP 1 in a T-SQL sub-query? 14 48
SQL query with cast 38 59
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…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

740 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