Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC connection 2

Status
Not open for further replies.

Neil Toulouse

Programmer
Mar 18, 2002
882
GB
Is there any way of finding out whether an ODBC connection for SQL Server, has been configured for Windows or for SQL Server authentication?

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Following on from this...

Basically, I have a form from which the user selects the ODBC connection they want to use, including a username and password if required.

Before they move on, I want to check this connection is OK (basically by connecting to it). If they have not entered the username and password correctly, I don't want the ODBC dialogue appearing requesting the correct info, I just want it to error out so I can throw a message saying there's an issue.

From what I can tell you can only turn off the dialogue using SQLSETPROP only when you have successfully made the connection!

If you have Windows authentication set in the ODBC connection, it doesn't matter if you specify username and password in the SQLCONNECT() statement as it is simply ignored, and I only want to show the username/password fields if they are required by the connection.

is any of this possible?

I like work. It fascinates me. I can sit and look at it for hours...
 

Neil,

This is an excellent question. I wish I knew the answer. (I'm also wondering why I haven't come across this issue before. It seems such an obvious requirement.)

I can only that, as far as I understand it, it's SQL Server itself that determines the type of authentication, not the ODBC driver. I would have thought the driver simply passes a connection request to the server, which accepts or rejects it. But what do I know?

Hope you get an answer.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
I do not have an answer for you, but...

Could you use something like
faq184-4674
to examine the workstation registry contents at
"HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\

To see:
1. If the appropriate DSN exists at all
2. Examine the DSN properties under the specific DSN register entry
(sorry - I do not know which one(s) specifically define authentication type)

Good Luck,
JRB-Bldr
 
Neil,

As Mike said I don't think you can determine which method SQL Server will use to authenticate the connect (I would think it would be a security concern if you could), but you should be able to turn off the dialogue prompt prior to creating a connnection using:

=SQLSetProp(0,'DispLogin',3)

From VFP 8.0 Help: "To specify Visual FoxPro default settings at the environment level, include 0 as the statement handle."

Hope that helps.



Mike Reigler
Melange Computer Services, Inc
 
mreigler

I don't believe it! I was staring at that help page for ages yesterday, but never actually read the top line!!

Thanks for that, it should be enough to do want I want to achieve!

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
...and this has led on to another problem/issue!

If I don't display the dialogue box, there is a delay of about 50 seconds before it fails, no matter what value I set "ConnectTimeOut" too!

is this normal?

I like work. It fascinates me. I can sit and look at it for hours...
 
scrap that!

it must by system! It is now failing in less than a second without me changing anything!

these things come to bug us...!

I like work. It fascinates me. I can sit and look at it for hours...
 
jrbbldr

Thanks for this! Have finally got around to having a play and, yes, this FAQ can be used!

Bascially, if you have 'Windows authentication' setup in the ODBC connection, a line appears in the appropriate connection in the registry 'Trusted_Connection' with a value of 'Yes'.

If it is via SQL authentication, then the line doesn't exist, and so can be trapped for.

Excellent! Many thanks :)

I like work. It fascinates me. I can sit and look at it for hours...
 
...and just add, don't forget you can set SQL server to be Windows, SQL or both for authentication, and so you can select either via the ODBC connection.

I like work. It fascinates me. I can sit and look at it for hours...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top