I have a Delphi Win32 application that uses TAdoConnection to connect to MS SQL Server. It works fine in at least a hundred of users, in different environments, OSs, SQL versions and servers.
The connection string is retrieved from file on a shared network drive (with readonly access, so nobody can change it), from the same folder as the application itself (so everybody uses the same binary).
Recently two customers reported the following error (each of them in just one XP machine, all other users are ok):
The application is opened, with a shortcut, as every other user does, but it raises a Connection time-out error. The standard procedure when the application has any connection problem is to bring up the windows “Data Link Properties” dialog box.
The “Data Link Properties” dialog box comes up with the correct information. Pressing the [Test Connection] button, without any modification, confirms that: it displays, without delay, the “Test connection succeeded.”.
If you then press [ok], to close the wizard, the application runs smooth and fast as with the other users.
Why that opening the “Data Link Properties” dialog box fixes the connection (but not the connection string, does remains the same)? And how can I avoid this?
Thanks in advance for any help.
Do you set any properties on the connection in code after loading the UDL?
That could explain the difference in behaviour...
Please post the connection open code as well as the UDL content (open UDL-file with notepad).
Thanks for your replay and interest!
No, the connection string is the same. The TAdoConnection object’s string is used verbatim in the properties editor. That’s why it is so strange.
I’m now searching if the “Data Link Properties” dialog box makes some kind of Win Registry modification (like changing the default protocol) that fails (so each time I open the application the same error happens) but temporally fixes how the connection is done (just a hunch).
The actual connection string is:
Provider=SQLOLEDB.1;Password=****;Persist Security Info=True;User ID=sa;Initial Catalog=MYDB;Data Source=SYSTEMSEREVER
The connection open code is the Delphi’s standard: promptDataSource( h, stringConn );
Wow this is very strange. I would try to specify network protocol and (if tcpip) network port in the connection string to make sure its using the same protocol in both situations.
A long shot but worth testing.
Network Library=DBMSSOCN; and Data Source=SYSTEMSEREVER,1433 for server name.
Finally I had an opportunity to check in-loco the described problem… and found the cause!
As we discussed, I added the parameter
but had the same effect: connection time-out error.
As a last attempt, I forced Named Pipes protocol changing it to
And worked! I think it is now clear: a failed MDAC installation prevented a TCPIP connection; the Data Link Dialog (some how) changed the protocol to NP establishing connection.
Thanks for your interest and time. I hope this text helps to other people to.
TRY TO CHANGE THE COMPUTER NAME
CHANGE it to ---->192.168.1.1\LINKED
SHOULD FIX THE PROBLEM!!!