Hi Derek, Константин

procedure getpiece (Sender: TObject);
begin
  if form1.edit1.Value <= form1.edit2.value then
    begin
      form1.edit3.text := replacestr(form1.edit1.text, decimalseparator, '.');
      form1.edit4.text := replacestr(form1.edit2.text, decimalseparator, '.');
    end  else
    begin
      form1.edit3.text := replacestr(form1.edit2.text, decimalseparator, '.');
      form1.edit4.text := replacestr(form1.edit1.text, decimalseparator, '.');
    end;
end;

Все о "сводничестве" и "женитьбе"
https://oracleplsql.ru/joins-sqlite.html
- https://www.w3schools.com/sql/sql_join.asp
- https://zametkinapolyah.ru/zametki-o-my … elect.html

Patriot10200 wrote:

Банальный отсев по номеру авто, спасибо, раньше с SQL вообще не пытался связываться, но буду стараться потихоньку изучать, Спасибо еще раз, но все таки мне не дает покоя прикол с обычным поиском, почему после поиска в расходе получается 0 вместо суммы?


Здесь дело в другом.
Нельзя оставлять записи в статье расходов(поле деньги) или дохода(поле деньги) NULL.
Вам же известна особенность SQLite c хранением и преобразованием типов, если нет - читайте, учитесь.
Как только попадается запись NULL далее колонка становится текстовой и получить сумму уже нельзя.
Вот первая запись в расходе это NULL и вы бы еще больше удивились если бы у вас была третья строка.
После втрой строки в доходе где NULL в третьей вы тоже не увидите результат.
Определите значение по умолчанию для колонок 0 и соответственно в форме где сохраняете доход/расход.

4

(13 replies, posted in General)

Any component in MVD can be created in the graphical shell or dynamically while the program is running. When created, a component has mandatory properties: class, name, dimensions... events... etc. .  Some properties can be changed dynamically while the program is running. But any access to the component and changing its properties is possible only after its creation. Otherwise it causes an error.
But overall the program is working.

5

(2 replies, posted in SQL queries)

The SQLExecute function has the form

SQLExecute( ' SELECT ....  ' );

sqlDate -  Returns the date value of the component for use in SQL queries. The property value already contains escape quotes. In the case of an empty value, it will return NULL.

example:  SQLExecute ('INSERT INTO tablename (fieldname) VALUES ( ' + Form1.DateTimePicker1.sqlDate + ' )');

sqlValue - Returns the id of the selected record in the component, for use in SQL queries. In case of empty value, it returns NULL string. The property value already contains escape quotes.

example: SQLExecute('INSERT INTO tablename (fieldname) VALUES ( ' + Form1.ComboBox1.sqlValue + ' )');.

The use of CAST is not required.
Requires familiarity with MVD, SQLite.

https://myvisualdatabase.com/help_en/Co … ndEve.html

https://www.sqlite.org/index.html

https://myvisualdatabase.com/forum/view … ?pid=50515

https://myvisualdatabase.com/forum/view … ?pid=50517

6

(1 replies, posted in SQL queries)

You mixed everything into one pile.
As far as I understand, this is the part about checking the IF... condition.
Let's break down what you wrote:

SQLExecute('select count(*) from cars where date=''' + cars.DateTimePicker1.sqlDate + '''') <> 0 And (+cars.ComboBox1.SelectedCount+ ) > 0

1.- this query is compared with 0. Ok.

SQLExecute('select count(*) from cars where date=''' + cars.DateTimePicker1.sqlDate + '''') <> 0


2. Do you think this is the correct spelling of the ComboBox function?
- what is this?

(+cars.ComboBox1.SelectedCount+ ) > 0

   Maybe just

cars.ComboBox1.SelectedCount > 0

3. An IF with several conditions should look like this:

 IF (x>y) and (a <> b) THEN ....

4.- are you sure that in your cars table in the date column the time consists of 0?

where date='

7

(5 replies, posted in General)

(SELECT group_concat(kind||" "||number, ", ") 
FROM Treeno 
    left join treekind on treeno.id_treekind=treekind.id
WHERE TreeNo.id_pesticide=pesticide.id) 

8

(2 replies, posted in General)

Everything works without errors.

If you pay attention to the inscription “Specify field name for columns” and match the fields of the database and the CSV file in the table under the inscription, you will succeed.

9

(10 replies, posted in General)

Hi Derek


Lara.0080, First we need to explain about the format.
Date and DateTime are stored in the SQLite database as "2024-03-12 12:25:09.000". If you want to compare only the date you need to extract the date from this format. In SQLite you can use the Date() function. If you do not select the date, then changing any number over time will not allow you to make a correct comparison.
In your case it will look something like this
WHERE Date (Date1)=Date ('+ code1.DateTimePicker2.sqlDateTime +' )
You need to become more familiar with SQLite.


Also note that Derek uses sqlDate in his examples, which allows you to store date + time with zeros in the database. This makes later comparisons easier. However, if you are storing real time, you will need to use the Date() function in SQLite.

Here is the answer in this definition:
"The Windows Image Acquisition (WIA) Automation Layer is a full-featured image manipulation component that provides end-to-end image processing capabilities. The WIA Automation Layer makes it easy to acquire images from digital cameras, scanners, or Web cameras, and to rotate, scale, and annotate your image files."
This is about scanning and it works. But the conversion to PDF needs to be checked.
And MVD is intended for something else. Although you can hammer in a nail with a microscope.)

11

(7 replies, posted in General)

Hi Derek,


It's even easier

if vpath = '' then vweb.navigate('about:blank');

It also wouldn’t hurt to check for the presence of a file in the directory before opening it.

darko.bublic wrote:

... Can MVD use the flatbed scanner directly from the program?
Thank you for your reply.


Com port has nothing to do with this.
Directly from the program you can.
But this is not for a beginner and will require you to have sufficient knowledge to write appropriate scripts.
If you are ready to search, read and learn, then you will succeed.

13

(7 replies, posted in General)

Hi Derek,

The simplest solution is to create a blank page (html file) or with an inscription. If the request does not return a name, load a blank page.

procedure Form1_TableGrid1_OnCellClick (Sender: TObject; ACol, ARow: Integer);                                          //** if column2 clicked, then retrieve the relevant .pdf file
begin
  if acol = 2 then
    begin
      vpath := sqlexecute('select doclocation_filename from mydocuments where id = "'+form1.tablegrid1.sqlvalue+'"');
      vweb.navigate(vpath);
      if vpath = '' then vweb.navigate('C:\  . . . \pdf document viewer\documents\empty.html');

    end;
end;

The option of permanently re-creating TWebBrowser is also possible.

14

(9 replies, posted in General)

tcoton wrote:

Duplicate records is against the main purpose of a database, you should not have duplicated data in a database, use relationships.


Don't confuse people.
Data in records may be repeated. For example, yesterday two identical shipments of goods were shipped to the same recipient. Two identical actions. Real case? So, in order for the same data to be present in the database, there is a unique primary key column, which guarantees that the records will be different. But the data may be repeated.
In this case, Identity asks how to check the data and, in case of a match, allow/disable recording using a question.

procedure frmCreate_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
  frmcreate.edit6.text := replacestr(uppercase(frmcreate.edit1.text + frmcreate.edit2.text + frmcreate.edit3.text + frmcreate.edit4.text + frmcreate.edit5.text),' ','');
  if sqlexecute('select count(*) from dedomena where duplicatecheck = "'+frmcreate.edit6.text+'"') > 0 then
    begin
     if (MessageBox('Dupplicate records. Continue save ?','WARNING !!!',MB_YESNO + MB_ICONWARNING + MB_DEFBUTTON2) = IDNO)
      and (frmcreate.edit6.text <> frmcreate.edit7.text) then cancel := true;
    end;
end;

Brian, Sorry, I didn't look at the sender)))


I'm using a Required parameter but defining the value for the field directly on the form. The value 0 is not informative for me.

p.s. By the way, MARIADB 10.10.3 does not allow you to create from 0.

You are trying to show me that MYSQL does not support 0 or 'now' in date and time. This is known.
But this is not a drawback of MYSQL, but a feature of SQLITE.
For SQLITE, there is no strict correspondence between a given column type and its contents in a cell,
and this is described in the SQLite documents.
As for the default date value, you can assign it in the form in which you define this value.
For example, by writing it in a script.

Similar errors (“Invalid default value for 'Date_Column’) occur if the table has already been created in the database.
Both for SQLite and MYSQL/MARIADB.
I was unable to reproduce your situation for both DATE and ROLES.
All tables are created without errors if the database is clean.
After creating the tables, an attempt to set the field flag to mandatory results in an error (“Invalid default value ....)
You can attach an example or describe step by step how and what you do to reproduce your situation.

If you create tables in a MYSQL/MARIADB database, you are required to create a connection (name/password and database name) without creating tables in third-party programs. When you start the program and connect to the database, MVD will automatically create tables in your database (subject to all permissions in MYSQL/MARIADB). There are no problems with dates in MYSQL/MARIADB from versions 5.6 to 8 or 10 in MYSQL/MARIADB. Just tested. Brian right

19

(5 replies, posted in General)

Once again you ask a question that is different from your project (does not contain such a part) and what is broken is not clear.

You took a more universal route. By using SQL queries.
1. For such purposes, you can create a temporary SQL table (CREATE TEMPORARY TABLE ...).
   This will save you from growing the database in the future.
2. To generate the final result, pay attention to the SQL function - union.

If you export all the records that are on the screen, you just need to use a query that displays the records on the screen.

MVD also has its own function ExportToCSV(,,,,,,,).

20

(5 replies, posted in General)

The message to you indicates the line number where the error is.
If you search the forum for the word TSaveDialog, then on the first page
you will see an example of using the file save dialog.

This will allow you to resolve the error.

21

(5 replies, posted in General)

you can do this using a hidden staging table.
In the main table you select the records you need. By clicking the Export button, your rows are duplicated into an intermediate table. Once the operation is complete, you insert the first row into a staging table with the data you need and export to CSV.

Derek's post;


https://myvisualdatabase.com/forum/view … 879#p37879

23

(1 replies, posted in General)

While working on SunRise, it was a discovery for me to support the functions YearOf(), MonthOf(), DayOf()
for each date element separately. Perhaps for some, this will also be good news. See example.

24

(2 replies, posted in General)

The main menu on Form1 can be hidden, but can also be displayed at any time,
if necessary, using either the mouse or hotkeys.

25

(6 replies, posted in General)

Date_Appo = CURRENT_DATE||' 00:00:00.000' - All entries for current day

SUBSTR(Date_Appo, 1, 10) = CURRENT_DATE - All entries for current day

DATE(Date_Appo) LIKE CURRENT_DATE - All entries for current day

Date_Appo LIKE '2024-02-18%' - All entries for current day months

Date_Appo LIKE '2024-02%' - All entries for this month

DATE(Date_Appo) BETWEEN DATE(CURRENT_DATE, '-7 day') AND CURRENT_DATE - All entries for last 7 days

https://www.sqlitetutorial.net/sqlite-like/

https://www.sqlitetutorial.net/sqlite-between/

https://www.sqlitetutorial.net/sqlite-in/

...