When opening a recordset I sometimes get the error:-
Run-time error '-2147467259 (80004005)':
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.
I am using Windows Integrated Security. The strange thing is the rest of
the program works and even the same bit of code that is crashing will have
worked dozens of times a minute before. When the error happens it debugs
back to VB, where I can immediately attempt to open the recordset again and
it subsequently works.
Any clue of the problem?
Thanks,
Chris
Thank you for using MSDN Newsgroup! It's my pleasure to assist you with your issue.
First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you received a run-time error when your VB
application connected to a SQL 2000 Server (SP3) with Windows Authentication using ADO.
Additionally, the problematic code did work before and later it failed with that 'Login failed'
error. However, when it was debugged in VB, it worked again.
Have I fully understood you? If there is anything I misunderstood, please feel free to let me
know.
Looking at the nature of this issue, it would require intensive troubleshooting and I need to set
your expectation that such a random problem is complex to troubleshoot in newsgroups. If the
issue is urgent, you may contact Microsoft Product Support Services directly via
http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
If you'd really like to see if we can help address the problem in newsgroup or community
members can provide suggestions on this issue, please help narrow down the problem so
that we can move closer to the cause of the problem:
1. Use Query Analyzer (QA) to connect the SQL Server with either Windows Authentication or
SQL Authentication (Mixed Mode) to see if the problem is on a Service side or on the Provider
side.
2. Try to use SQL Authentication to connect the server to see if the VB application can work
fine.
3. Use the Component Checker Tool to check your MDAC version and compare the version
number of each MDAC DLL file to a list of the DLL files that are shipped with each MDAC
version. Additionally, if the MDAC version is not the latest one, it is recommended that you
install the MDAC 2.71 SP1 Refresh. For more information, please see the following KB:
301202 HOW TO: Check for MDAC Version
http://support.microsoft.com/?id=301202
4. Please check if there is any Network issue related to this problem.
Chris, thank you for your patience! If there is anything more I can do to assist you, please feel
free to post it in the group.
Best regards,
Billy Yao
Microsoft Online Support
----------------------------------------------------
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.
Firstly, yes you have understood my problem exactly.
I will first try and eliminate the network just so we don't do any
unnecessary work!
I've just created a simple VB project that has just this query in it. I've
got it going around in a loop trying to reproduce the error. As yet it has
not crashed.
I will work on building the simple EXE with further code until I can
reproduce the same error.
I'll keep you posted.
Thanks,
Chris
Function GetPassenger(PassengerID As Long) As String
Dim cmdTemp As New ADODB.Command
Dim recTest As New ADODB.Recordset
With cmdTemp
.ActiveConnection = "Provider=SQLOLEDB.1... etc"
.CommandText = "SELECT DefaultPassenger FROM Passengers WHERE
PassengerID = " & PassengerID
.CommandType = adCmdText
End With
recTest.Open cmdTemp, , adOpenForwardOnly, adLockReadOnly
Set cmdTemp = Nothing
With recTest
If .BOF And .EOF Then
GetPassenger = ""
Else
GetPassenger = !DefaultPassenger & ""
End If
.Close
End With
Set recTest = Nothing
End Function
This is a very simple function that retrieves a value by running a query. I
put this query in an endless loop retrieving random values. Eventually,
even on the local machine the program crashes.
I guess because it crashes on the local machine the network is out of the
equation?
Thanks,
Chris
Can you paste the error message here? Based on my understanding, you put
the function in a dead loop, and the app crashes randomly. In this case,
please also try to find which line crashes the app, so that I can deliver
my assistance more quickly.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Run-time error '-2147467259 (80004005)':
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.
I've also had the error:-
Run-time error '-2147467259 (80004005)':
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access
denied.
Both errors happen on recordset open line:-
recTest.Open cmdTemp, , adOpenForwardOnly, adLockReadOnly
Thanks,
Chris
"Kevin Yu [MSFT]" <v-k...@online.microsoft.com> wrote in message
news:8KxD%23m$0DHA...@cpmsftngxa07.phx.gbl...
It seems that there's something wrong with the connection string. Have you
chosen "Use Windows NT Integrated Security". Can you paste the connection
string here? Is the SQL server on your local machine or on a remote
machine? If on a remote machine, Are the computers in a workgroup or in a
domain?
Furthermore, you can try the following steps for troubleshooting:
1. Create a text file in your computer and rename it to .udl.
2. Double click the .udl file and the Data Link Properties dialog box will
be opened.
3. Set the conneciton in the dialog box and click "Test connection" button
to test it.
4. If "Test connection succeeded!" is displayed, click OK to close the
dialog box.
5. Open the .udl file in Notepad.
6. Copy the 3rd line as the connection string and try again with your app.
I created the connection string as you suggested. The string it created was
exactly the same as what I was using. Yes, I am using Windows NT Integrated
Security. This is the string I am using:-
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=PHCS;Data Source=CHRIS_SONY
I've ran the sample application on both a machine local to the SQL Server
and another machine (Both machines produce the error). Neither of the
machines are in a domain, but are both in the same workgroup. After
experimenting some more I've come up with some more conclusions...
1) Three different errors seem to occur (randomly). It can be any of
these:-
a) Run-time error '-2147467259 (80004005)': [DBNETLIB][ConnectionOpen
(Connect()).]SQL Server does not exist or access denied.
b) -2147467259 - Login Failed for user '(null)'. Reason: Not associated with
a trusted SQL Server connection
c) -2147467259 - Cannot generate SSPI context.
2) I created this sample application with just this simple query in it and
made it run in a continuous loop. I opened it up 30+ times spread between
to the two machines. If I just leave this going it only generates an error
very occasionally (maybe every 20 minutes or so). However, if I open up my
main application that uses the same database it make the error occur in the
test applications every two or three attempts - e.g. I continually open and
close my application and after three attempts one or more of the sample
applications running will generate an error (Up to 6 or 7 of the 30+
applications can generate the error at the exact same time). So, I decided
to trap everything my application was doing when it loads. So what is going
on.... Well my application runs about 20 stored procs to return some data.
These are very simple stored procs that are retrieving simple settings
stored in the database. Then the program opens up about five recordsets (on
after another) that also run some very simple queries (returning very little
data). Nothing complicated. The only other thing I spotted when running my
application using SQL profiler was that a stored proc called
sp_reset_connection is running after most stored procedures. Could this be
causing a problem? After a quick search on the internet it appears this is
something ADO automatically runs? Could it be trying to close the wrong
connection or something?
Thanks,
Chris
"Kevin Yu [MSFT]" <v-k...@online.microsoft.com> wrote in message
news:1gUnCeP1...@cpmsftngxa07.phx.gbl...