Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One remote view, many identical source tables: how to do
Message
 
 
To
04/06/2002 16:52:30
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00664726
Message ID:
00664734
Views:
22
If you are set on remote views, I suggest using SPT to retrieve the data, then make the results cursor updatable. The following is code I use to make a cursor updatable. All my tables have a single integer PK field and this field is always named KeyID.
   PROCEDURE MakeUpdatable
      LPARAMETERS tcCursor, tcTable
      IF VARTYPE(tcCursor) <> 'C'
         RETURN .f.
      ENDIF
      IF VARTYPE(tcTable) <> 'C'
         RETURN .f.
      ENDIF
      IF NOT USED(tcCursor)
         RETURN .f.
      ENDIF
      LOCAL lnSelect
      lnSelect = SELECT()
      SELECT (tcCursor)
      CURSORSETPROP('Tables', tcTable)
      ** The next property must include every remote field matched with the
      ** view cursor field.
      LOCAL lcFields, lcUpdate, llRetVal
      lcFields = ''
      lcUpdate = ''
      FOR lnI = 1 TO FCOUNT(tcCursor)
         IF NOT EMPTY(lcFields)
            lcFields = lcFields + ', '
         ENDIF
         lcFields = lcFields + FIELD(lnI, tcCursor) + ' ' + tcTable + '.' + FIELD(lnI, tcCursor)
         IF UPPER(FIELD(lnI, tcCursor)) == 'KEYID' && PK field is not updatable
            LOOP
         ENDIF
         IF NOT EMPTY(lcUpdate)
            lcUpdate = lcUpdate + ', '
         ENDIF
         lcUpdate = lcUpdate + FIELD(lnI, tcCursor)
      ENDFOR
      llRetVal = CURSORSETPROP('UpdateNameList', lcFields, tcCursor)
      llRetVal = CURSORSETPROP('KeyFieldList', 'KeyID', tcCursor)
      ** The next property specifies which fields can be updated.
      llRetVal = CURSORSETPROP('UpdatableFieldList', lcUpdate, tcCursor)
      ** The next property enables you to send updates.
      llRetVal = CURSORSETPROP('SendUpdates', .T., tcCursor)
      llRetVal = CURSORSETPROP('UpdateType', 1, tcCursor)
      llRetVal = CURSORSETPROP('WhereType', 3, tcCursor)
      SELECT (lnSelect)
      RETURN llRetVal
>(Thanks to all who responded to my question yesterday regarding making DSN-less SQL connections.)
>
>My data source will consist of 16 SQL Server databases. Each database represents one of our company's divisions, and contains identically named and structured tables. For example, each database contains a table named APVENDOR, each with identical field names, types, & lengths. Is it possible to set up a single view for use in accessing these tables, simply switching the active database and table depending on which company division the user chooses to be working with? I don't really want to set up sixteen potential views for each table or situation that I need to handle.
>
>Using advice received yesterday, I have been working with connections and remote views. Once I have set up a remote view, I don't seem to be able to switch the database. "Hacking" the .dbc file reveals that the database name resides in a memo field, but I don't see a simple way to change that setting.
>
>Thanks in advance for any assistance,
>Randy
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform