1515
а- Why the trigger gives out a mistake?
- How it is necessary to establish a buffering mode for data sources of form?
- Why there can be problems with deleting of records from the table, having Primary Key?
- Why created in Visual FoxPro the tables have not code page 1251?
- I have created Local view with two tables and use a keyword Join from View designer, and it does not work how I expected. What is a problem?
- Whether there is a simple opportunity to change a folder (site) of a database at FoxPro application?
- In VFP 6.0 at attempt to receive connection with the table of a database Visual FoxPro through ADO-ODBC I receive mistakes which not exist. Whether there is an opportunity to make what I want?
- At the reference to the stored procedure I receive a mistake that the procedure is not found. How correctly it is necessary to call the stored procedures?
- In the application I use one database, and I need to open some table of another, and it is impossible to me. Can't I work with several databases?
- It seems, that simple task: for example, there is a table of approximately such structure: a code of the client, date of payment, sum. The codes of the client in the table repeat.Is it possible by one inquiry to receive result: a code of the client - date of last payment - sum. And that should be broken into two subquery - ugly :-(
- I have VFP 6.0+SP3 VS6 and now has appeared class Session. Whether will show an example of its use?
- I don't create Connection object in database. Simply in a code I write lnHndl = sqlconnect (lcDSN, lcLogin, lcPassw) and would like to prevent error message, to treat it in program. How to me to make it?
- Has installed VFP6.0, and though "Prompt for code page" is set, change Code Page dialog does not happen :-( In what a problem?
- Whether it is possible to execute a command PACK for the table through ODBC?
- Is it possible from the VFP-program to add/change/delete in ODBC Administrator DSN?
- In any way I can not receive complete Rushmore optimization (SYS (3054) returns the optimization partial) on the table with an unique character field. That it could be?
- It would be desirable automatically to have field of datas of a type "date of the last modifications", however in trigger update for the table it is impossible at me. Why and how it can be made?
- How to receive the updated data in network version in case Private Data Session is used?
Q: Why the trigger gives out a mistake?а
A: Because on the moment of performance of the trigger the data, do not satisfy to its requirements. To understand, what exactly occurs, it is best to look after the appropriate site of a code in debugger. Without the analysis of a concrete situation it is possible to assume, that the buffering of records the changeable table does not corresponding to logic of modification registered in a code. For example, you insert new record into the table, without use of properties default value for fields, only were going to bring in respective changing, and the trigger already has fulfilled.
Q: How it is necessary to establish a buffering mode for data sources of form?а
A: The best variant: to reset property Form.BufferMode of a Form in value 2-Optimistic. In this case, if properties Form.DataEnvironment.Cursor(i).BufferModeOverride at sources of the given Form will be established in value by default: 1-Use Form Setting(Default), all marked above problems are removed automatically, however you are free to establish a way of buffering of cursors of a Form how will find necessary.
Q: Why there can be problems with deleting of records from the table, having Primary Key?а
A: The given problem arises because it is not possible always to follow correct setting of a system mode Set Deleted in On at use of the table, and in state Off certainly requirements on uniqueness of value Primary Key are broken. To remove this problem follows indexes appropriate as Primary Key, and Candidate to nominate value of the filter containing expression: Not Deleted(). It is necessary to have in view of if told above accepted it is true if there are no problems of perfomance, because Rashmore optimization will not be carried out in this case. Otherwise you should think about an opportunity again to use of before mark as deleted records (see. RECALL Command)
Q: Why created in Visual FoxPro the tables have not code page 1251?а
A: It is strange, if at you localized version Windows is established (check Regional Settings and set Russian). But in any case, it is necessary to achieve, that the value received from the function Cpcurrent() was 1251. If it is enough to choose it by your machine, item Tools/Options Е and by changing a mode Collate sequence in value Russian on a tab Data, to execute Set As Default. Further, not bad would be to be passed under the projects, created by you, and in each of them, by opening dialogue Project Info Е, on a tab Files to execute Update Native Code Page for display of code pages of files included in the project. The program Cpzero will help you to change code pages of any files with structure DBF. At last, by machines of the clients using feasible files, it is necessary to try to ensure installation of code page by addition of parameter: CODE PAGE = 1251 in files Config.fpw in the current catalogues of these executed files.
Q: I have created Local view with two tables and use a keyword Join from View designer, and it does not work how I expected. What is a problem?а
A: Microsoft Visual FoxPro 5.0a has a problem at creation Local view, containing a key word Join: in the list of the tables following at once the key word FROM, the complete list of the tables participating in query is located whereas at presence Join, it is required to exclude from it those tables, which are used directly in Join. Further, if in Join more than two tables are involved, the conditions of "connection" of records, i.e. parameters ON, should follow at once for appropriate Join, while designer LocalView creates group of parameters ON at the end of the list of parameters Join (though I am not absolutely sure concerning last). I write the utility ModeView.exe, which will help you to make the appropriate updating Local view of a database, the truth it should use after any changes with preservation yours of Local view, containing Join directly ahead of their use in the appendix [to receive a copy ModeView.exe]. See also
http://support.microsoft.com/kb/q157254/Q: Whether there is a simple opportunity to change a folder (site) of a database at FoxPro application?а
A: If speech goes about a property Database at objects CursorX in DataEnvironment of the forms and reports, you can easily it change in runtime in an event DataEnvironment.BeforOpenTables() (at least since version 5.0), or in event MyBaseForm.Load(), by set MyForm.DataEnvironment.AutoOpenTables = .F. and by use MyForm.DataEnvironment.OpenTables() from code. However you can also:
Placed at new site of a database, while its former site is already inaccessible, in editing mode consistently to open all forms and reports and on a question on impossibility to open a database to specify its new site. The brought changes, certainly should be saved at an exit from dialogue of editing of the form/report.
If the offered variant seems to you tiresome, you can make respective alterations, by opening files *.scx and *.frx "manually". (See for *.scx of a field: Class and Properties, and for *.frx of a field: Name and Expr. It is necessary to you to edit property Database at object Cursor).
At last last variant can be executed from the program. For this purpose I write the utility ChangeDb.exe. [to receive a copy ChangeDb.exe]
Q: In VFP 6.0 at attempt to receive connection with the table of a database Visual FoxPro through ADO-ODBC I receive mistakes which not exist. Whether there is an opportunity to make what I want?а
Q: At the reference to the stored procedure I receive a mistake that the procedure is not found. How correctly it is necessary to call the stored procedures?а
A: Before attempt of calling to any stored procedure from a database you should make its as active, using a command SET DATABASE TO dbc_name. The problem can arise during of compilations, if code included call to a stored procedure immediately and database is not included in the project. In this case it is enough in addition to place advantage EXTERNAL ARRAY MyDbcFunction in a code immediately before the call to a stored procedure to explain this feature to the compiler.
Q: In the application I use one database, and I need to open some table of another, and it is impossible to me. Can't I work with several databases?а
A: First of all, I advise you to look property Exclusive for all of Cursor's in DataEnvironment of your forms and reports, look also value of parameter Open Exclusive in Tools\Options... on tab Data, very much can be, that these parameters required opening databases - tables in Exclusive mode ... For opening the tables it is necessary to do from code something similarly to the following:
IF !DBUSED("MyDbc")
OPEN DATABASE [full_path]MyDbc.dbc SHARED
IF !DBUSED("MyDbc")
?CHR(7)
MessageBox("Can not open database: MyDbc", 16, "Error")
RETURN .F.
ENDIF
ENDIF
SET DATABASE TO MyDbc
IF !INDBC("MyTable", "Table")
?CHR(7)
MessageBox("No table: MyTable in database: MyDbc", 16, "Error")
RETURN .F.
ENDIF
USE MyDbc!MyTable IN 0 SHARED
Q: It seems, that simple task: for example, there is a table of approximately such structure: a code of the client, date of payment, sum. The codes of the client in the table repeat.Is it possible by one inquiry to receive result: a code of the client - date of last payment - sum. And that should be broken into two subquery - ugly :-(а
A: Something as next:
SELECT * FROM MyDbё!Payments p ;
WHERE STR(p.idclient) + DTOS(p.date) IN;
(SELECT STR(p.idclient) + DTOS(MAX(p.date));
FROM MyDbё!Payments p;
GROUP BY p.idclient)
... by though two in one, ...and if for the concrete client, it is possible so:
SELECT TOP 1 *;
FROM MyDbё!Payments p;
WHERE p.idclient = ?idclient;
ORDER BY p.date DESC
Q: I have VFP 6.0+SP3 VS6 and now has appeared class Session. Whether will show an example of its use?а
A: Somehow approximately so:
#DEFINE C_DATABASE "D:\Program Files\Microsoft Visual Studio\";
+"MSDN\99OCT\1033\SAMPLES\VFP98\Tastrade\Data\Tastrade.dbc"
RELEASE goSec
PUBLIC goSec
goSec = CreateObject('MyclsSession')
DEFINE CLASS MyclsDE AS DataEnvironment
Comment = 'MyMultiUsedDEObject'
InitialSelectedAlias = 'Employee'
ADD OBJECT Cursor1 AS cursor WITH ;
Database = C_DATABASE, ;
Alias = 'Employee', ;
CursorSource = 'Employee', ;
Exclusive = .F.
* ...
PROCEDURE BeforeOpenTables
*... change if need
ENDPROC
ENDDEFINE
DEFINE CLASS MyclsSession AS Session
DataSession = 2
Name = 'MySession'
oDataEnvironment = NULL
FUNCTION Init
This.oDataEnvironment = CreateObject('MyclsDE')
IF VARTYPE(This.oDataEnvironment) = 'O'
This.oDataEnvironment.OpenTables()
ENDIF
ENDFUNC
ENDDEFINE
Pay attention, to a moment of an event MyclsDE.BeforeOpenTables() the instance of object MyclsDE already exists, and you can from a code change it directly ahead of opening of sources of datas.
Also It is necessary to have in view, that a method AddObject (...) of any container and function CreateObject (...) works differently:
1) method This. AddObject ('MySession') adding instance of class Session into containers having propery DataSession, - never and any new DS not creates... and acts so:
- if the parent object has property DataSession = 2-Private DS, - then into DS of this parent object.
- If the parent object has property DataSession = 1-Default DS, - then into DS Default(1)
2) in turn, behaviour of creation instance object of a class Session through CreateObject ('MySession') a little bit other:< br >
- if the created object has property DataSession = 2-Private DS, - then always as new DS, pay attention, value of a property MyForm.DataSessionID overwrite into value of the last created session
- if the created object has property DataSession = 1-Default DS, - then into DS Default (1)
Q: I don't create Connection object in database. Simply in a code I write lnHndl = sqlconnect (lcDSN, lcLogin, lcPassw) and would like to prevent error message, to treat it in program. How to me to make it?а
A: Try to do
=SQLSETPROP(0,"DispWarnings", .F.)
=SQLSETPROP(0,"DispLogin", 3) && DB_PROMPTNEVER
Q: Has installed VFP6.0, and though "Prompt for code page" is set, change Code Page dialog does not happen :-( In what a problem?а
A: Read carefully in MSDN section "SET CPDIALOG"... and there is written:
ON - (Default) Displays the Code Page dialog box when you open a table
and the following conditions are true:
- The table is opened exclusively.
- The table is not marked with a code page.
In other words, what for call Code Page dialog, if to interchange a code page
in any case will fail :-)
Q: Whether it is possible to execute a command PACK for the table through ODBC?а
Q: Is it possible from the VFP-program to add/change/delete in ODBC Administrator DSN?а
Q: In any way I can not receive complete Rushmore optimization (SYS (3054) returns the optimization partial) on the table with an unique character field. That it could be?а
A: Try to do SET DELETED OFF before your SQL-SELECT :-)... If in the latter case receive complete optimization, try to add an index INDEX ON DELETED() TAG DEL into your table... Now, as I hope, the optimization will be complete and with SET DELETED ON
Q: It would be desirable automatically to have field of datas of a type "date of the last modifications", however in trigger update for the table it is impossible at me. Why and how it can be made?а
A: Infortunately in Update trigger it is impossible to make modifications datas, concerning which it is called, as an infinite recursion :-( and in Update trigger it is possible only to make changes to other table have communication from an initial table type one-to-one. Otherwise you are able to do it:
- in Record Rule for table to call SP
- in MyBaseForm.Save()
- in events Valid() appropriate controls
Q: How to receive the updated data in network version in case Private Data Session is used?а
A: Really, in process on the party of the client by an interval of updating of data is set by second parameter in SET REFRESH (if not use SYS (1104) [<- in VFP 6.0 see: Q269284 Knowledge Base Articles INFO: Undocumented Function SYS(1104) or VFP 7.0], which makes of updating at the moment of call... well or REQUERY() in a case Remote View/SELECT : -) to receive new updating data... no other way
Further, even if Cache is also updated (obviously through call SYS (1104), or the interval specified by second parameter in SET REFRESH has passed), in any case, that the updated data in the current record "is real new ", it is required move point of record (type GO (RECNO ('ChangedTable')) IN ChangedTable)
In other words, GO (RECNO ('ChangedTable')) IN ChangedTable (or other way get updated datas, for example Refresh() for binding controls) earlier than the interval specified as second parameter in SET REFRESH, for VFP 5.0 has not expiredа