Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 195236 - Last Review: July 1, 2004 - Revision: 4.3
How To Get ADO Default Connection Information
This article was previously published under Q195236
Default connection properties might differ by driver. In your application,
it might be important to obtain the ADO version number because you might
need to know whether the driver uses server-side or client-side cursors,
supports transactions, or opens tables as read-only by default.
The following sample allows you to determine the default connection
properties for a driver. It creates a DSN-less connection to an existing
driver and displays the default connection properties for that driver.
To use this sample code, you must have Microsoft Data Access Components
(MDAC) version 2.x or later installed, which is included in the data
components of Visual Studio 6.0 or can it be downloaded from the following
Web site:
Create and execute the following program, substituting the name of your
driver, server, and database in the 'lcConnString' variable:
* The following program creates a DSN-less connection
* and shows the defaults for the Connection object for
* this specific driver
#DEFINE CR CHR(13)
oConnection = CREATEOBJECT("ADODB.Connection")
lcConnString = "DRIVER={SQL Server};" + ;
"SERVER=YourServerName;" + ;
"DATABASE=YourDatabaseName"
lcUID = "YourUserID"
lcPWD = "YourPassword"
oConnection.OPEN(lcConnString, lcUID, lcPWD)
lcTitle = "Default connection properties"
lcText = "Attributes: " + LTRIM(STR(oConnection.ATTRIBUTES)) + CR + ;
"Command Timeout: " + LTRIM(STR(oConnection.CommandTimeout)) + CR + ;
"Connection String: " + oConnection.ConnectionString + CR + ;
"Connection Timeout: " + ;
LTRIM(STR(oConnection.ConnectionTimeout)) + CR + ;
"Cursor Location: " + ;
LTRIM(STR(oConnection.CursorLocation)) + CR + ;
"Default Database: " + oConnection.DefaultDatabase + CR + ;
"Isolation Level: " + LTRIM(STR(oConnection.IsolationLevel)) + CR + ;
"Mode: " + LTRIM(STR(oConnection.Mode)) + CR + ;
"Provider: " + oConnection.Provider + CR + ;
"State: " + LTRIM(STR(oConnection.State)) + CR + ;
"Version: " + oConnection.VERSION
=MESSAGEBOX(lcText)
If the connection is successfully created when you run this program, a
message box appears that contains information about the defaults for the
connection. Properties such as the cursor location (2 = Server-side
cursors, 3 = Client-side cursors) might differ for different drivers.
For definitions of the return values for Mode, State, IsolationLevel, and
CursorLocation, please see the include file Adovfp.h included with the
sample program Rs2Dbf.exe in the Microsoft Software Library. To download
Rs2Dbf.exe, please see the following article in the Microsoft Knowledge
Base:
192692Â
(http://kbalertz.com/Feedback.aspx?kbNumber=192692/EN-US/
)
SAMPLE: Rs2dbf.exe Converting ADO 2.x Recordset to VFP Cursor
APPLIES TO
- Microsoft Visual FoxPro 5.0 Standard Edition
- Microsoft Visual FoxPro 5.0a
- Microsoft Visual FoxPro 6.0 Professional Edition
- Microsoft Data Access Components 2.1 Service Pack 2
- Microsoft Data Access Components 2.5
- Microsoft Data Access Components 2.6
| kbdatabase kbhowto kbsqlprog KB195236 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate