Microsoft KB Archive/155392

= How To Creating a Connection to SQL Server Without a Datasource =

Article ID: 155392

Article Last Modified on 3/14/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Data Access Components 2.5

-



This article was previously published under Q155392



SUMMARY
When creating a connection to access remote data, you can create a connection that does not require an ODBC datasource. Because this method does not require an existing ODBC datasource, you do not have to be concerned with setting up the datasource in the ODBC administrator. This simplifies the task of application distribution.



MORE INFORMATION
The following steps outline how to create a connection that does not require an ODBC datasource. The connection will be called CONNECT1, and it accesses a SQL Server backend with the following attributes:   Server Name = SQL1 Logon User ID = USER Logon Password = password DATABASE = pubs You can create the connection either programmatically or using the Connection Designer. Both of these methods will be addressed.

Creating the Connection Programmatically
 Open a database in which to store the connection. Enter the following command in the Command window:

CREATE CONNECTION CONNECT1 CONNSTRING "DRIVER={SQL Server};        SERVER=SQL1;UID=USER;PWD=password;DATABASE=pubs"

NOTE: You should enter this command on one line.

Creating the Connection Using the Connection Designer
 Open a database in which to store the connection. From the File menu, click New. Specify a new connection.</li> In the Connection Designer, select the "Connection String" option button.</li> Enter the following for the Connect String:

DRIVER={SQL Server};SERVER=SQL1;UID=USER;PWD=password;DATABASE=pubs

</li> Close the Connection Designer, and save the connection as CONNECT1.</li></ol>

To test the connection, enter the following in the Command window:

?SQLConnect('CONNECT1')

A return value greater than zero indicates a successful connection.

Additional query words: DSNLESS

Keywords: kbhowto KB155392

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.