Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: question about VFP remote view

  1. #11
    Senior Member
    Join Date
    Jul 2019
    Posts
    175
    Hi Hank,

    May I know which VFP command or function I should use to extract the component out of the remote view table?

    Thanks & Best Regards

  2. #12
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    1,962
    Hi WJ,

    Look in VFP help for DBGetProp().

    Hank

    Hank

  3. #13
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,101
    You can get the list of all views (all code is executed in VFP9):

    Code:
    SELECT 0
    use "C:\Program Files (x86)\Microsoft Visual FoxPro 9\Samples\Northwind\northwind.dbc"
    BROWSE FOR objecttype='View'
    An example of extracted component for the view named 'order_subtotals'

    Code:
    CLOSE DATABASES all
    OPEN DATABASE "C:\Program Files (x86)\Microsoft Visual FoxPro 9\Samples\Northwind\northwind.dbc"
    cResults = DBGETPROP("order_subtotals", "View", "SQL")
    ?cResults
    SELECT OrderDetails.OrderID, Sum( (OrderDetails.UnitPrice*OrderDetails.Quantity*(1-OrderDetails.Discount)/100) *100) AS Subtotal FROM OrderDetails GROUP BY OrderDetails.OrderID
    Web link for HELP dbgetprop(): http://www.yaldex.com/fox_pro_tutori...ee4e19eb8f.htm

    Make this for every view in your database.
    You can test your code first in Northwind database, so we can help you.
    Last edited by josipradnik; 2019-12-20 at 03:38.

  4. #14
    Senior Member
    Join Date
    Jul 2019
    Posts
    175
    Hi guys,

    Thank you so much for helping me out!

    Best regards

  5. #15
    Senior Member
    Join Date
    Jul 2019
    Posts
    175
    Hi josipradnik,

    Should I use dbgetprop() to get the string connection value?

    Thanks & best regards

  6. #16
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,101
    If your DBC has ConnectionName for each view, I guess you should find it :

    Code:
    DBGETPROP("order_subtotals", "View", "ConnectName")
    On your system then you can explore this named ConnectionName for the connection string.

    Maybe your DBC has connectString writen in it, then:

    Code:
    DBGETPROP("yourConnection", "Connection", "ConnectString")
    As I can see, Northwind does not have Connection record in DBC.
    You should explore all properies of DBGETPROP function against your DBC.


    From VFP9 Help:

    CREATE [SQL] VIEW [ViewName] [REMOTE]
    [CONNECTION ConnectionName [SHARE] | CONNECTION DataSourceName]
    [AS SQLSELECTStatement]

    Parameters
    ...
    [REMOTE]
    Specifies to create a view using tables from a remote data source, or a remote view. Omitting REMOTE creates a view using local tables.

    [CONNECTION ConnectionName[SHARE] | CONNECTION DataSourceName]
    Specifies the name of a previously defined connection or an existing data source to connect with when opening the view.

    NoteNote
    When you use the CONNECTION clause and specify the name of a connection or data source, Visual FoxPro first searches the current database for a connection with the name you specified. If the specified connection cannot be found, Visual FoxPro searches for an established ODBC data source with the specified name. Therefore, if your current database contains a named connection with the same name as an ODBC data source on your system, Visual FoxPro uses the named connection.

    If you use a CONNECTION clause with the CREATE SQL VIEW command, you do not need to include the REMOTE keyword. Visual FoxPro identifies the view as a remote view from the inclusion of the CONNECTION keyword.
    Last edited by josipradnik; 2019-12-20 at 06:27.

  7. #17
    Senior Member
    Join Date
    Jul 2019
    Posts
    175
    Hi Josipradnik,

    What should I do when I get this error message from the logs?

    Fri Dec 20 23:14:49 2019
    **** Lianja error ****
    OPEN DATABASE "C:\Program Files (x86)\Microsoft Visual FoxPro 9\Samples\Northwind\northwind.dbc"
    ^
    Database 'c:\program files (x86)\microsoft visual foxpro 9\samples\northwind\northwind.dbc' - The filename, directory name, or volume label syntax is incorrect.

  8. #18
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    1,962
    Hi WJ,

    There are two approaches, and you are attempting to mix them.

    1) Open the database in VFP and collect the information needed to generate the VFP views. This is what I have been describing. The DBGETPROP is all documented in VFP help, etc., so you could easily create a VFP table with the information and then access that from Lianja.

    2) USE the VFP .dbc database file from Lianja, and find the correct information to generate the views it's a little more complicated than Josip indicated In fact, if you need information other than the view name and the field names (you do) you will be out-of-luck. If you Google on "VFP DBC property field" you can read why you will be out of luck. With time a decoding scheme could be created.

    Hank
    Last edited by HankFay; 2019-12-20 at 11:39.

  9. #19
    Senior Member
    Join Date
    Jul 2019
    Posts
    175
    Hi Guys,

    May I know which view property should I set in the degetprop() function to extract list of properties that I set inside the remote view table ?

    Thanks & Best Regards

  10. #20
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    1,962
    Hi WJ,

    Look up the two sets of properties, in Lianja and VFP. Some from VFP won't match what is in VFP. Read the materials, then think it through. If you need to get more information on a property to decide, go find more information on that property.

    Hank

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us