Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQLOLEDB Connection Error In Excel VBA Spreadsheet

Posted on 2011-09-20
4
Medium Priority
?
1,017 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

There are some very powerful Dynamic Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a di…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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 anti-spam), the admin…
Loops Section Overview

783 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