Solved

SQLOLEDB Connection Error In Excel VBA Spreadsheet

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

705 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