>>>Hi all,
>>>I'm having a tough time solving an issue and hope the experts around here can help.
>>>
>>>I've written a small VFP9 exe that connects to SQL Server 2005 using SQLSTRINGCONNECT(). Running it from the VFP command window, it works like a charm. I run the exact same EXE from Windows explorer and an MS SQL Server Login error displays, Connection failed... etc. I have tried many different things to resolve this but just can't seem to solve it.
>>>
>>>I am using an ODBC connection.
>>>
>>>It seems to be a permissions issue but I just can't figure why the VFP IDE would have no problem but the standalone exe does.
>>
>>Have you tried right-clicking on your EXE in Windows Explorer and running it as an Administrator?
>>
>>What authentication mode are you using for SQL Server - Windows or SQL Server?
>>
>>What is the exact error you're getting?
>
>Hi Al,
>Thanks for responding.
>1. I have tried running as administrator. Same problem.
>2. Authentication mode varies... I have tried Windows, trusted connection, SQL Server.
>3. I have attached only one error (as I have tried all kinds of different tacks).
>What gets me is that *every* time, when I do anything in the VFP IDE, connection works no problem.
>Ed
Well, something must be different. The error shown in the image seems pretty specific, it can't find the SQL Server instance.
- Do you have a CONFIG.FPW baked into the EXE? Is it the same one loaded by the IDE?
- I've seen some environments where VFP is invoked via a batch file, and the batch file first SETs some environment variables, which are then accessed in VFP via GETENV( ). Do you have anything like that going on in your IDE?
- You could put DISPLAY MEMORY TO FILE
SomeFileName just before your attempt to connect so you can see if your connection string is as expected
Putting some of the above together, I've seen environments where an environment variable or public memvar set via CONFIG.FPW is used as a "Test" flag. If the flag is set, it connects to a test instance of SQL Server, otherwise it connects to the production instance. Maybe your IDE is running in "Test" mode and can find the test instance, and the EXE is in Production mode and can't find the production instance.
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up