Condividi tramite


Using the Visual FoxPro OLE DB Provider to Access Data

To access existing Visual FoxPro data from Visual Studio applications, and from Visual Studio using the Server Explorer or ActiveX Data Objects (ADO) in code do the following:

To use the Visual Studio Server Explorer to access Visual FoxPro data

  1. In Visual Studio, click the Server Explorer tab, or select Server Explorer from the View menu.

  2. Add a connection through the Visual FoxPro OLE DB Provider in the Providers list.

    You must be able to specify or browse to the Visual FoxPro database you want to access by providing path and filename information.

To access Visual FoxPro data in Visual Studio

  • Establish a connection object, create a data object, specify the OLE DB Provider and the data source in a connection string, and then access and manipulate data using appropriate properties and methods.

ADO

In Visual FoxPro this access looks like this:

   OConn = CREATEOBJECT("ADODB.Connection")
   OConn.ConnectionString = "provider=vfpoledb.1;;
      data source=.\testdbc.dbc"
   OConn.Open

In Visual Basic 6.0, access takes the following form:

   Sub ADOOpenVFPDatabase()
      Dim cnn As New ADODB.Connection
      cnn.Open "Provider=vfpoledb;" & _
         "Data Source=.\TasTrade.dbc;"
      cnn.Close
   End Sub

For a complete explanation of connection string syntax, see the Microsoft OLE DB 2.5 Programmer's Reference and SDK Guide.

See Also

OLE DB Provider for Visual FoxPro | Accessing a Visual FoxPro Data Source | Accessing a Visual FoxPro Data Source from Office Components | Language Reference for OLE DB Development | Visual FoxPro as a Data Source