Solved

OPENDATASOURCE Sometimes fails

Posted on 2010-11-18
9
1,296 Views
Last Modified: 2012-05-10
I have a view created by OPENDATASOURCE.  The view is

SELECT *
FROM OPENDATASOURCE ('SQLNCLI','Data Source = mydatasource;trusted_connection=yes')
.dbname.tablename

Randomly I get the following error when I run a select on the view from my workstation.

Msg 18456, Level 14, State 1, Line 1

Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

OLE DB provider "SQLNCLI" for linked server "(null)" returned message "Invalid connection string attribute".

 

If I immediately log into the server and run it there (with no problems) I can jump back to my desktop and run it (almost like I cleaning out some memory or something).

 

So I wanted to see if there was an execution count that would trigger the error.  I ran a loop selecting * from the view for well over an hour on my machine..  The query was executed over 225,000 times.  When it was done, I ran the select statement alone ~5 times with no problems.  I leave my session for a few minutes I come back and get the error again and of course log into the server run it come back…no problems.

 
Any ideas?
0
Comment
Question by:gdspeare
[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
  • 5
  • 4
9 Comments
 
LVL 29

Expert Comment

by:sammySeltzer
ID: 34166370
Try using integrated security like:


SELECT *
FROM OPENDATASOURCE ('SQLNCLI','Data Source = mydatasource;Integrated Security=SSPI')
.dbname.tablename

Open in new window


because you are using trusted connection, anonymous login will always fail.
0
 
LVL 29

Expert Comment

by:sammySeltzer
ID: 34166454
No, use standard security is what I meant, sorry.

Integrated security and trusted connection set to true are the same.

So, should be:

SELECT *
FROM OPENDATASOURCE ('SQLNCLI','Data Source = mydatasource;UserId=Your_Username;Password=Your_Password')
.dbname.tablename
0
 

Author Comment

by:gdspeare
ID: 34167284
why do you think think this would address the ocassional error?  I can run it just fine.  

plus this is going into an app.  users won't be entering any credentials.
0
Back Up Your Microsoft Windows Server®

Back up 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.

 
LVL 29

Expert Comment

by:sammySeltzer
ID: 34167578
>>plus this is going into an app.  

Web app, you mean? Your original post didn't indicate that.

if it is .net, you may wish to consider adding <impersonate = "True">

>>users won't be entering any credentials.

True. They don't have to because once you create an account on the db useing SQL Server Authentication Mode and add you give it read or execute or whatever permission you wish to give it, and you enter that account into your code as I indicated, then it will authenticate any user accessing the app.

0
 

Author Comment

by:gdspeare
ID: 34167833
what you are suggesting makes sense. However, it doesn't aswer the question of why my query bombs out from my workstation after some event (which i can't identify) and then is successful after I run the query on the server directly.  

I'm also not convinced that I would get the same issue b/c I'm an admin on both boxes.  So if i'm running into this issue a sql specific account would too
0
 
LVL 29

Expert Comment

by:sammySeltzer
ID: 34167881
What I think is happening is that in your iis, you are using windows integrated authentication which means that anyone accessing your app must be a windows domain user.

So, when you log in as an admin, by default, you have sysadmin account and things work fine.

If you try to run without a domain account, you run into the issue you are having.

So, the decision you have to make is whether to allow all users to have domain account OR, you do as I suggested and use ONE SQL Server account that has both execute and and atleast readOnly permission.
0
 

Author Comment

by:gdspeare
ID: 34168160
i'm not using IIS - I'm logged into the server user SSMSE on my workstation and when the query fails I log into a full install on the server.

I haven't integreated the query into the asp app because of this issue.
0
 
LVL 29

Accepted Solution

by:
sammySeltzer earned 500 total points
ID: 34168593
0
 

Author Closing Comment

by:gdspeare
ID: 34168796
not what I was hoping to learn, but it seems like this is my answer.  Thanks.
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

Suggested Solutions

Title # Comments Views Activity
Running total between 2 sql tables in Sql 6 50
Call to SQL server times out 5 55
Any benefit to adding a Clustered index here? 4 38
Datatable / Dates ? 4 30
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 article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

734 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