26

(15 replies, posted in General)

When you say it fails, what do you mean? Look at your object properties for the datetimepicker. Do you have the checked property turned on? If so, then uncheck it.

27

(22 replies, posted in General)

blackpearl8534,
The reason you are only getting one row is because you are using variables. Variables only hold one instance of information. With each iteration of your while loop you are overriding the previous iteration of variables. So after you finish the while loop you load the report variables with essentially the last iteration of the recordset variables. That's why your report only shows the last record of the table.

28

(22 replies, posted in General)

blackpearl8534,
I know you have been asking this question on the Forum, but I am not aware of a way to go directly from a recordset to a dataset. I have not seen anything on that and without Dimitry's support I think you may be stuck. However, as an alternative you could populate a local temporary Sqlite database with your report records. Then you could report off of that. I have attached a sample. I do not have Sql Server so I used Access, but the concept is the same. I would recommend selecting only the records and fields needed for the report for efficiency purposes. I apologize if you already thought of this and determined that it is not workable.

29

(4 replies, posted in General)

Pragma is a sqlite function that can be used to retrieve various technical info about the database. Below is a link for more information about its specific uses.


[https://sqlite.org/pragma.html]


The SqlQuery using the pragma function retrieves all the columns of a table and puts them in a dataset called ColResults. Then using the while statement I go through each row of the dataset which in this case are the columns in the specified table. I check for the col name of Field2. If it finds the column name Field2 it sets the boolean field FieldExists to TRUE otherwise it remains FALSE and can be added to the table in the ALTER statement. Hope this helps.

30

(4 replies, posted in General)

Attached is a sample way of doing it through script. The table is named TestTable with one column named Field1. The form has a button to check for Field2 column existence and if it does not exist, it can add it. I am using the form for user interaction, but typically you would probably do this without user interaction. You can do this behind the scenes without showing the form at all.

31

(8 replies, posted in General)

Quite honestly I never understood it either.  According to a post by Dimitry it is used in an internal algorithm in the program but it has no affect on the speed.  I never check this check box and my apps work just fine. I have plenty of lookup tables without it checked.

32

(4 replies, posted in General)

If I understand you correctly, you cannot copy a label to a combobox. However, if you want to set the combobox to the value of a label, you can do that with a one line script. This requires that your label is actually a value in the Lookup table. See attached for an example. The label on Form1 has a value of "B". This value is used to select the id of the record containing this value in the Lookup table. The combobox item id is set to the selected "B" record id value. The combobox now displays the same value as the label "B" on the form.

33

(7 replies, posted in Script)

It works the same. What version of MVD are you using? You need to be on version 6 for standard access control. Also, make sure the tables "_Role" and "_User" are defined in your MySql database.

34

(4 replies, posted in General)

Form1.Edit1.Text := Form1.Label1.Caption;

35

(2 replies, posted in General)

I am not familiar enough with using non-MVD databases within MVD, but here is an option you can try. Select the records you want from your sql server and load them into a temporary sqlite or mysql database and then do your report out of there. Then delete the data from the temp database.

36

(25 replies, posted in General)

sdpc62,
First of all you do not need to distribute the .vdb file to your users and you do not need to distribute the script.pas file in your script folder. You still need these files for development purposes. So you should copy your application folder and remove these files before distributing your application to your users. That should be enough, however, you can embed and hide the remaining files and folders inside the .exe file by using a software tool such as Enigma Virtual Box. It's free and easy to setup for your programs.

37

(18 replies, posted in General)

For MySql use the DateDiff function.

DateDiff(enddate,startdate)

38

(18 replies, posted in General)

Again, I am not sure I totally understand, but I put in a calculated field to calculate the days left from now till the end date.

39

(18 replies, posted in General)

senseyesenseye1983,
If I understand correctly see attached.

40

(7 replies, posted in General)

Remove the last plus sign quote (+' )

41

(7 replies, posted in Script)

I totally agree with CDB. It seems you are making this more difficult than it really should be. See attached. You can accomplish what you want with very little script. And the only reason for the script is because of the awkward setup of the forms. I did make an assumption and that is there will only be one record in this table. If there is going to be more than one record then your forms will need to change to accommodate such.

42

(12 replies, posted in Script)

Unfortunately I can't give a specific answer because I do not know your situation or computer setup. I don't know if you are creating this project for yourself or for a business, friend or someone else. All I can do is explain the syntax of the DirectoryCopy command. You will need to know the various paths to your users' storage devices and place those paths into the command.

DirectoryCopy('From Path','To Path');

The 'From Path' is the current location of your photos. This is the path where your photos are located for your app.


The 'To Path' is the path to the location you want to store your backup. This can be a path to an SD card, USB drive, CD, external hard drive, a server drive, a Cloud drive, etc. You just type the path inside the quotes.


So you can either hard code the path inside the quotes, as mentioned above, or make a settings file and then have the user select the backup path and store it in your settings file. Then the DirectoryCopy command can be filled in with the value in your settings file. This way if a user wants to change the backup location, you will not need to change the program to accommodate. This may be a little more advanced for you, but the ability is there.

43

(12 replies, posted in Script)

If you are the one who is managing the photos, you can simply use Windows Copy and Paste to backup your photo folder. But if you want to do it within MVD, you can use the DirectoryCopy function to do the same. See attached example project. In this example the backup folder is inside the application folder. I do not recommend this. Your backup folder should be in another location, preferably on another media.

44

(12 replies, posted in Script)

Not sure I understand your question. Are you asking about backing up and restoring the folder containing your photos?

nitin.ingale08,
I don't want to take your money. I am not that greedy especially to fellow MVDer's. If you attach your project or database or at least the database structure with some sample data, I or somebody else on the forum can take a look and maybe provide a solution. It really depends on the complexity of the project and time commitments.

46

(12 replies, posted in General)

To answer your second question, you need to place your database on a shareable resource such as a separate server machine which serves all the client workstations. The database needs to be mapped to a drive letter. If your USB stick in the router can be mapped to a drive letter, then you can define the location in the client settings.ini file. But I seriously doubt you can do that. I've not heard of that capability. But if you can see the USB stick in your Windows explorer then you should be able to access it. Plus it needs to be shareable to all your users.

47

(12 replies, posted in Script)

First, your project is not really a working application and even after my changes it still is not. No insert feature except upon opening the app and not sure why the two save buttons. One of them does not really do anything.


Second, the DbImage component buttons are not trappable. At least I am not aware of anything to intercept the events on the open button. Therefore, as a possible solution to your needs, I hid the component buttons and created my own OPEN button (visible when you mouseover the image component). The check for the size of the file occurs when selecting an image in the dialog. If the file size is within your size range then it will display otherwise it will present an error message and not display. The BUTTONSAVE button is the real save button to save the record.


I changed your DbImage component from StoreFile to LinkFile. I highly recommend storing images outside your database. It can dramatically slow your app especially if you have a lot of records holding images.


Hope this helps.

48

(12 replies, posted in Script)

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
   Size,kb: Integer;
begin
   Size := GetFileSize('YourImageFile.png');
   kb := Round(Size/1024);
   If (kb >= 100) and (kb <= 500) then
      ShowMessage('File size is in range')
     else
      ShowMessage('File size is not in range');
end;

49

(2 replies, posted in Script)

Try this: (Not tested for syntax)

procedure OnTimer;
var sMessage,sId: string;
begin
     sId := SQLExecute('SELECT id FROM reminder WHERE strftime(''%d.%m.%Y %H:%M'', datetime) <= strftime(''%d.%m.%Y %H:%M'', ''now'',''localtime'') ');
    If sId <> '' then
      Begin
         sMessage := SQLExecute('SELECT message FROM reminder WHERE id = ' +sId);
         if SendMail('smtp.mail.xxxx.your-server.de', 'notification@qualitymanagementsystems.eu', 'xxxxxxxx', 465, 
           'notification@qualitymanagementsystems.eu', 'wayne.hollowayr@gmail.com' , 'Subject', 'Message') then
            SqlExecute('Delete From reminder where id = '+ sId);  // Here is your delete record statement
      End;

      // I commented the following. Not legitimate.
          //Begin
         // Form1.Button3.click;
         // end;
end;

You basically have three options. You can use a third party software such as SqliteStudio, or the built-in import process within MVD, or write your own scripts. It is very difficult to recommend a solution without knowing your data structures in your databases. The more complex your database is (multiple relationships, lookups, etc) then it may be necessary to write your own scripts because you need to properly populate the joining keys between tables.