Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to suppress ODBC client driver error dialogs?
Message
De
11/02/2016 18:12:18
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows Server 2012 R2
Database:
MS SQL Server
Application:
Desktop
Virtual environment:
VirtualBox
Divers
Thread ID:
01631344
Message ID:
01631353
Vues:
62
>>I'm testing for SQL Server connectivity from a VFP app. My first attempt is to set a connection string, then try to get a handle to the SQL Server instance using SQLSTRINGCONNECT( ).
>>
>>My initial testing is with the SQL Native Client 11.0.
>>
>>This works great if the parameters are correct. However, what I actually want to do with this code is handle the case where the parameters are wrong (or there's a network problem etc.)
>>
>>If there's something wrong the client driver first puts up a helpful error dialog (see image SQLDialog1.png). Then it puts up a dialog offering the user the chance to manually make parameter changes and try again (see image SQLDialog2.png). Only after the user manually cancels out of both dialogs does the SQLSTRINGCONNECT( ) call finish and return -1.
>>
>>Does anyone know how to suppress these dialogs? This program has to run unattended.
>>
>>In a perfect world, it would be great to somehow get the contents of the first dialog (which is actually quite helpful) so I can subsequently log it.
>
>
>sqlsetprop(0, 'DispLogin', 3)
>sqlsetprop(0, 'DispWarnings', .f.)
>
Thanks, Hugo - that's what I was looking for. The important thing to note (for me) was 0 as the first parameter of the calls - from Help: "To specify Visual FoxPro default settings at the environment level, include 0 as the statement handle." This lets the function work *before* a connection is (not) made.

UPDATE: for lurkers - on a failure of SQLSTRINGCONNECT(), AERROR() contains all the information in the first dialog of my initial post (plus more).
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform