Article ID: 198427
Article Last Modified on 11/1/2003
-or-
*!* Set Properties for the view.
DBSETPROP('MyTest', 'View', 'UpdateType', 1)
DBSETPROP('MyTest', 'View', 'WhereType', 3)
DBSETPROP('MyTest', 'View', 'FetchMemo', .F.)
DBSETPROP('MyTest', 'View', 'SendUpdates', .T.)
DBSETPROP('MyTest', 'View', 'UseMemoSize', 255)
DBSETPROP('MyTest', 'View', 'FetchSize', -1)
DBSETPROP('MyTest', 'View', 'MaxRecords', -1)
DBSETPROP('MyTest', 'View', 'Tables', 'dbo.PREF')
DBSETPROP('MyTest', 'View', 'Prepared', .T.)
DBSETPROP('MyTest', 'View', 'CompareMemo', .F.)
DBSETPROP('MyTest', 'View', 'FetchAsNeeded', .F.)
DBSETPROP('MyTest', 'View', 'Comment', "")
DBSETPROP('MyTest', 'View', 'BatchUpdateCount', 1)
DBSETPROP('MyTest', 'View', 'ShareConnection', .T.)
*!* Use the view.
USE MyTest
*!* Use the AFIELDS() function to get the column names.
=AFIELDS(aPrefArray)
*!* Loop through the array.
FOR i=1 TO ALEN(aPrefArray,1)
*!* Set Field Level Properties for the view MyTest.
IF i=1
DBSETPROP('MyTest.'+ALLTRIM(aPrefArray[i,1]),'Field','KeyField', ;
.T.)
ELSE
DBSETPROP('MyTest.'+ALLTRIM(aPrefArray[i,1]),'Field','KeyField', ;
.F.)
ENDIF
DBSETPROP('MyTest.'+ALLTRIM(aPrefArray[i,1]),'Field','Updatable', ;
.T.)
DBSETPROP('MyTest.'+ALLTRIM(aPrefArray[i,1]),'Field','UpdateName', ;
'dbo.PREF.'+ALLTRIM(aPrefArray[i,1]))
NEXT
*!* Code begins here
#DEFINE CONNECTSTRING 'DRIVER={SQL Server};' + ;
'SERVER=My_Server;DATABASE=PUBS;UID=UserName;PWD=StrongPassword'
gnConnHandle=SQLSTRINGCONN(CONNECTSTRING)
SQLCommand="CREATE TABLE PREF (PREF CHAR(10), TAG CHAR(20))"
TestVal=SQLEXEC(gnConnHandle,SQLCommand)
CREATE DATABASE Reserved
CREATE CONNECTION KeyWords CONNSTRING CONNECTSTRING
CREATE SQL VIEW MyTest REMOTE CONNECTION KeyWords ;
AS SELECT * ;
FROM dbo.PREF PREF
*!*MODI VIEW MyTest
SQLCommand="DROP TABLE PREF"
TestVal=SQLEXEC(gnConnHandle,SQLCommand)
=SQLDISCONN(gnConnHandle)
CLOSE ALL
*!* Code begins here.
#DEFINE CONNECTSTRING 'DRIVER={SQL Server};' + ;
'SERVER=My_Server;DATABASE=PUBS;UID=UserName;PWD=StrongPassword'
gnConnHandle=SQLSTRINGCONN(CONNECTSTRING)
SQLCommand="CREATE TABLE PREF (PREF CHAR(10), TAG CHAR(20))"
TestVal=SQLEXEC(gnConnHandle,SQLCommand)
CREATE DATABASE Reserved
CREATE CONNECTION KeyWords CONNSTRING CONNECTSTRING
CREATE SQL VIEW MyTest REMOTE CONNECTION KeyWords ;
AS SELECT * ;
FROM dbo.PREF PREF ;
WHERE PREF.PREF=?mypreference ;
AND PREF.TAG=?mytag
*!*MODI VIEW MyTest
SQLCommand="DROP TABLE PREF"
TestVal=SQLEXEC(gnConnHandle,SQLCommand)
=SQLDISCONN(gnConnHandle)
CLOSE ALL
Keywords: kbdatabase kbprb kbpending kbcode KB198427