26

(15 replies, posted in General)

I'm not sure what you mean by getting data in grid2 without selecting any data in grid1.  isn't the point is that you do select some data in grid1 and the related data is displayed in grid2?
automatic display of data must start from somewhere. if it's from your textbox, then that's fine, otherwise it can be from another grid as well (i.e. the selected row).
there is a function/property of the grid control that allows you to determine the actual row selected by the user.
using this will allow you to get back the underlying data (keys, values, etc.) relate to that row of data.

edit: check out the properties "SelectedRow" (or "dbItemID") & "SelectedColumn" from the online help.

27

(15 replies, posted in General)

what you have in the picture seem to be on the right track; you just have to make sur that the raw data that the suer enters is as complete as possible and make sure the data flows (is saved) in the right tables with the correct linkages (primary and foreign keys).

as to your last question, the basic idea is as follows (the actual code/mechanics may not be correct and you will have to determine the actual correct syntax):

each grid/table/query should have a primary key associated with the data.
Grid 1                       Grid 2
key1  value              key2  fkey   value    <--- source table/query
1       A                       1        2        Blue
2       B                       2        4        Green
3       C                       3        3        Yellow  <-- this is a an example record that would be displayed in the Grid 2
4       D                       4        2        Red             based on the selection of "C" from Grid 1.  Other rows are shown
5       E                       5        4        Cyan           as examples of other possibilities that will not be included.

so that when the user select a row from Grid 1, say "C", then the key (or index) can be found, i.e. 3 and then using this key, we looks this up in the other Grid (2) using this key as the foreign key (fkey) to get the key/index of this data.

so after a selection ("C") is made in Grid 1, we have key1 = 3; Grid 2 data is dynamically generated using a query similar to:

select * from Table 2 where fkey = 3

I have used only simple Tables above as an illustration, but the data can come from other queries as well, however in a normalised database where each type of data (e.g. patient, results, test, etc.) should be in it's own table and if it is required elsewhere then it is referenced by it's table and key (like we were discussing in the above earlier posts).

28

(15 replies, posted in General)

I believe that what you want to use from your description are triggers.
They would work such that when the suer inputs certain data to populate fields in one table, that the triggers would activate and automatically populate some of the same data into other related tables.
The problem is that currently MVD does not support triggers directly, and they will have to be added using a 3rd party tool (I understand that SQLiteStudio has been the recommended tool mentioned in this forum before).

Note: Looking at some previous posts, it looks like you are already using this tool along with triggers for other parts of your project, so this shouldn't be new to you; you just have to expand on what you have already and make sure you populate the related tables correctly with the information you obtain from the user. cheers.

29

(3 replies, posted in General)

I'm not sure what the problem you are having actually is...you have basically already given the solution you want already yourself.
you just need to create a calculated field in your table and make the result (Total) equal to Quantity + (Came in) - (Sold out).
Please have a look at this thread, http://myvisualdatabase.com/forum/viewtopic.php?id=1110, as it looks to be very SIMILAR to what you want to do.

the function strtoint does not seem to be valid for sql statements, but thanks to your use of cast, i was able to get an example working for you - please have a look at the attached project (you will have to build the exe file or run in the ide).

the problem as you suspect is that the values stored in your table column are text and not integers; so to get the max value of the number starting at the 5th digit, you have to convert the text into an integer and perform the max function on that instead of the text (and the same in your check):
so it would look something like the following:

select max(strtoint(substr(t1.TelNr,-5 5))) from Telephony t1 where strtoint(substr(t1.TelNr,-5 5)) < 5560

and depending on what you are doing with the result, you may have to convert it back to a string.

32

(7 replies, posted in General)

it sounds like that this folder that is linked in the data field is not accessible from the other computer.
if the path to the folder starts with a drive letter, you have to make sure that the same path is mapped on all computers that will use the database.
if instead the folder used in your data field is in UNC format (i.e. something like \\server\folder\...\), then you have to make sure that the all the users that will be using any computer that needs access to the shared folder has the required permissions (to at least read, if not read and write) to that folder.
note that the above assumes that the folder in question is indeed a shared folder.

@timlitw
from your error message and the variable definition, it looks like the variable trfcontid is defined as a string, but is used to look up information in the table that expects it to be an integer.
the simplest way to overcome the error is either redefine the variabe as in integer (along with ContID), or to check the value before before passing it to the SQL statement:

if (trfcontid = '') then trfcontid = '0';

this would only solve the erro part of the problem and does not help to add it into the database if it is missing; you should be able to do this after the SQL is run and a checking the result of ContID, and actioning as appropriate.

34

(4 replies, posted in General)

If you need it to be in another language, then assuming that the structure of numbers as words is the same as for English, then I would use a combination of what Dmitry has given as the function ReplaceStr.

e.g. something similar to the below code snippet:

var
strNumber: string;
strNumberAsWords: string;

begin
strNumber := '123456';
ShowMessage(strNumber);
strNumberAsWords := ToWords(StrToFloat(strNumber), '', 0, False);
strNumberAsWords := Lowercase(strNumberAsWords);
ShowMessage(strNumberAsWords);
strNumberAsWords := ReplaceStr(strNumberAsWords, 'one', 'un');
//...2 to 8
strNumberAsWords := ReplaceStr(strNumberAsWords, 'nine', 'neuf');
//...11 to 18
strNumberAsWords := ReplaceStr(strNumberAsWords, 'nineteen', 'dix neuf');
//...more for 10, 20, 30, 40, 50, 60 70, 80, 90
//...more for hundred, thousand, million, billion, etc.
ShowMessage(strNumberAsWords);
end.

you may have to fiddle around a bit to get an accurate translated version though.

35

(1 replies, posted in Script)

I can find the following from the functions list under string functions:

leftstr == Copy(s, String; from, count: Integer): String
length == Length(s: Variant): Integer

Dmitry,

One quick and easy (interim) method (until you come up with a proper solution to this) would be to create a checksum/hash of every custom file created (script, report, etc) and to store these hashes in an internal system table and every time MVD starts, it would interrogate this system table and validate all the files needed.
There is already the MD5 function, so this shouldn't be too hard to implement.

BTW, MD5 is apparently not that secure anymore, so maybe you could add other algorithms like SHA-1 (also apparently not secure any more) or SHA-256, etc.

Cheers, Dennis.

Looking at the help file, if the field/column of the wanted value (A, B, or C) is already selected on the current record, then you should use the sqlValue property:

e.g. SQLExecute ('INSERT INTO tablename (id_groups) VALUES ('+Form1.TableGrid1.sqlValue+')');

If only the row is selected, but the field is not, or you want other fields, then you would use a combination of the function Cells and the function SelectedRow:

e.g. ShowMessage('value of column A: ' + Cells(1,Form1.TableGrid1.SelectedRow));

The above assumes that column A had index 1.

Hi Dmitry,  Is it possible to bulk load pictures into a database that has a picture field already defined as a field?

e.g. let's say i have a simple table with 2 fields, BookTitle of type TEXT and CoverPicture of Type IMAGE and I also have another external text file with a list of names of books and the local path to the book cover picture (JPGs); can I somehow run through each entry in this list and import the associated picture into the database table?

BTW, I know that storing pictures in the database itself it not the best in terms of performance and general database size, but the pics are small so it's not an issue at the moment.  Cheers, Dennis.

Wow! Again I am amazed at your responsiveness, both in terms of replying and in implementing requested features.
This is very much appreciated. Thank you.

Hi Dmitry,  Is it possible, either by script or by extra parameters passed to the MessageBox procedure/function to have the actual message box that is displayed, to automatically close after a period of time like (e.g.10 seconds) with no user input?  i.e. like a timeout functionality so that apps can be run unattended?
This would also be a useful function to have for error message popups as well. Cheers.

41

(3 replies, posted in General)

i always check what the current official version is by going to the homepage

42

(187 replies, posted in General)

Wow.  That was quick! (And very much appreciated).
While we're on the subject, would it be possible to add the corresponding read line function(s)?
This will probably need to be a bit different and need more commands (i.e. one to open the file, another to read a line from it, and another to close the file when finished, and probably another to check for EOF).  No rush on this request - next version would be fine wink

43

(3 replies, posted in Script)

Hi Dmitry, any chance you could replace the key combination of the replace function from Shift+Ctrl+F to just Ctrl+H (as is standard in at least Notepad and Wordpad)?  I have a hard time finding this until I did a search on forum topics.
Cheers

44

(187 replies, posted in General)

Hi Dmity,  I'd like to please request the addition of a simple text writing function that can append to the end of an existing file.  This would be very useful for logging and debugging.  At the moment, I have resorted to using a StringList and using the AddLine and SaveToFile methods of this class to output log text to a file - although it works, it is not very efficient as the whole StringList is Written each time I want to add a new line of text. Cheers.

45

(24 replies, posted in General)

i had already started an example when Dmitry replied, but completed it as i didn't want it to go to waste.
so please have a look at this example as well as the one posted above by the developer.

the compiled version and sqlite.dll file has been removed to reduce the archive size.

46

(12 replies, posted in General)

Hi Dimitriy,
Could you please keep the online (and offline) documentation updated with the most recent release version of MVD?
I suggest that you also implement some sort of version information for each component/property/method so that users know which items are relevant for the version of MVD that they are using.

e.g. for the new property dbLimit of the TableGrid component, this can be placed after the property name like:

dbLimit [1.48+]

47

(24 replies, posted in General)

isn't his what the http://myvisualdatabase.com/help_en/script/memo.html component is for?

using this component you do not need to add line breaks as each line is added using the Lines.Add function.

http://myvisualdatabase.com/help_en/components/memo.png

i see.  i'm glad i was mistaken about this then; but it is still not a completely robust system; as that script.dcu file can be removed or replaced (if the function names are somehow found/guessed)...may not be very likely, but still possible.  i.e. if the developer uses common function names like encrypt or decrypt or validate or checkpassword etc.

edit: i've just had a look at a script.dcu file and although ir is a bit messy, it is still in plain text (xml format), all the main guts of my custom script code is visible and can easily be extracted from this file.  needs to be properly compiled.

this is not exactly true, or more correctly, it is true but not very effective.
the reason is that with the current implementation of your scripting ability, it is all visible (and modifiable) as plain text files under the scripts sub-folder.
what is needed, is that the custom scripts be encrypted when stored/written (if kept as separate files), or the custom scripts to be compiled and linked directly into the main executable, so only a single program file is needed to run a developed database application (assuming that it doesn't have any custom reports as well).
even if we try to implement some sort of security or protection into the programs we make, as long as the scripts are unprotected themselves, then it would be easy for them to be reversed engineered to defeat any protection scripts that have been created.

50

(12 replies, posted in General)

Very nice work on the translation by The Engineer - although I have noticed that in the Scripts/TableGrid/Methods and Properties section for Color that the description looks to still be in Russian; not sure if there are other areas that are similarly untranslated.

I can also not seem to find any information on whether an english translation like this will be (or has been) included in the installation package for off-line reference - can you please answer this for me here?