Article ID: 147875 - Last Review: August 30, 2004 - Revision: 2.1 How To Use "DSN-Less" ODBC Connections with RDO and DAOThis article was previously published under Q147875 On This PageSUMMARY
With Microsoft Visual Basic versions 4.0, 5.0, and 6.0 for Windows, you can
specify your ODBC (Open Database Connectivity) driver and server in your
connect string when using RDO (Remote Data Object) and DAO (Data Access
Objects) which eliminates the need to set up a DSN (Data Source Name). We
call this a "DSN- Less" ODBC connection because you do not need to set up a
DSN in order to access your ODBC database server.
To do this, you specify a "driver=" and "server=" parameter in your connect string as in the following example. Note You must change Username= <username> and PWD =<strong password> to the correct values before you run this code. Make sure that Username has the appropriate permissions to perform this operation on the database. NOTE: The driver name must be surrounded by curly brackets. For example: "{SQL Server}." (CAUTION: DSN-Less connections will not work in Visual Basic 4.0 16-bit. If you try to use them you will get a General Protection Fault in module ODBC.DLL at 0006:080F.) MORE INFORMATION
In Microsoft Visual Basic version 3.0 for Windows, you had to create a DSN
that added an extra step when distributing your application because each
workstation had to have the DSN created in order to access the specified
server and database. This was done either manually with the ODBC Admin
utility, through code with the RegisterDatabase function, or through code
with the SQLConfigDatasource API function. For additional information on
how to do this setup manually, please see the following articles in the
Microsoft Knowledge Base:
123008
(http://support.microsoft.com/kb/123008/EN-US/
)
TITLE : How to Set Up ODBC Data Sources When Distributing an App
126940 (http://support.microsoft.com/kb/126940/EN-US/ ) : RegisterDatabase Fails After ODBC Version 2.x Installed 132329 (http://support.microsoft.com/kb/132329/EN-US/ ) : RegisterDatabase Method Does Not Modify ODBC.INI File Sample ProgramThe following RDO example uses a "DSN-less" ODBC connection so you do not need to set up a DSN with the ODBC Admin utility beforehand.
REFERENCES
Hitchhiker's Guide to Visual Basic and SQL Server, Microsoft Press. ISBN: 1-55615-906-4. APPLIES TO
| Article Translations
|
Back to the top
