Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

HOWTO: How to Create a Remote Connection or View Programmatically


View products that this article applies to.

This article was previously published under Q137944

↑ Back to the top


Summary

This article shows by example how to create remote connections and remote views programmatically.

↑ Back to the top


More information

The following code creates a database in which to store the remote view and remote connection. The remote connection is created first, and then the remote view is created by using the remote connection.

The data source used in this example is Sqltest, which is the name of the corresponding SQL Server ODBC driver that exists in the ODBC driver manager. The Pubs database comes with Microsoft SQL Server and contains a table called Sales.
   CLOSE ALL
   SET DEFAULT TO c:\temp
   * A view cannot exist without a database.
   * Create a database to contain view.
   CREATE DATABASE zdb

   * Create a connection for the view to use.
   CREATE CONNECTION zconn DATASOURCE sqltest USERID sa PASSWORD ""

   * Create the view using the remote connection.
   CREATE SQL VIEW zview REMOTE CONNECTION zconn AS select * from ;
      pubs..sales

   * Open the view and browse the resulting data set.
   USE zview
   BROWSE
				
By default, a view is not updatable. For information about creating an updatable view, please see the following article in the Microsoft Knowledge Base:
130413� How to Create an Updatable Cursor (View) to Update Table

↑ Back to the top


Keywords: KB137944, kbhowto

↑ Back to the top

Article Info
Article ID : 137944
Revision : 5
Created on : 3/14/2005
Published on : 3/14/2005
Exists online : False
Views : 550