101

(9 replies, posted in General)

unforgettable wrote:

Thank you brain. In this query LIMIT 1 means one step before and other 1 is an increment.

Limit is the number or record you want to fetch.

1. Limit 1, will be selecting the first record of the query
2. For Limit 1, 1, First 1 will be the offset(will skip 1 record), then the Next 1 will be the number of record you are selecting
3. For Limit 2, 1, This will skip 2 record, then select 1 record from the query

102

(9 replies, posted in General)

Hello unforgettable, StateOne:

I'm confused. are you just trying to access the last record of your table? If so then you can just do

Select  * from xyz ORDER BY id DESC LIMIT 1

In this way you don't have to include subquery. You don't want it to slow down your query especially for a well-populated table
Then for e.g. last id is 300, being no gap in the IDs, to access 299,

Select  * from xyz ORDER BY id DESC LIMIT 1, 1

for 298

Select  * from xyz ORDER BY id DESC LIMIT 2, 1

for 297

Select  * from xyz ORDER BY id DESC LIMIT 3, 1

and so on.

For the conditional, try elaborating further the result you want to obtain for us to look for a solution.

103

(2 replies, posted in General)

I'm not so sure to what you are trying to do here. Are you perhaps selecting all records from smsLogs? If so then, here's an untested code that might help you

procedure FormReport_SmsSendAllbtn_OnClick (Sender: TObject; var Cancel: boolean);
var
   Msg,smsNumber,smsServer1,SMS_API1,SenderName1 : string;
   sl,slParam: TStringList;
   j : integer;
   jDataStream: TJSONObject;
   jStatus, jSmsID: TJSONString;
   dt : tDateTime;
   SData: TDataSet;
begin
  SQLQuery('SELECT * from smsLogs', SData);
  
  // you might want to just initialize this and not include it in the loop
  SMS_API1 := SQLExecute('Select SmsAPI from Extras where id = 1');
  SenderName1 := SQLExecute('select SenderName from Extras where id = 1');//'BlackPearl';
  
  try
    while (not SData.EoF) do
    begin
      smsNumber := SData.FieldByName('smsNumber').asString;
      Msg := SData.FieldByName('smsData').asString;
      // ShowMessage(smsNumber+' '+Msg);
      slParam := TStringList.Create;
      smsResult := HTTPPost('http://api.veevotech.com/sendsms?hash='+SMS_API1+'&receivenum='+smsNumber+'&sendernum='+SenderName1+'&textmessage='+Msg+'',slParam);
      // slParam.Free;

      sl:=TStringList.Create;
      sl.Text := smsResult;
      jDataStream := nil;

      jDataStream:=TJSONObject(TJSONObject.ParseJSONValue(sl.Text));
      if jDataStream <> nil then
      begin
        jStatus := TJSONString(jDataStream.GetPairByIndex(0).JsonValue);
        jSmsID := TJSONString(jDataStream.GetPairByIndex(3).JsonValue);
      end;
      ShowMessage(jStatus.Value);
      if (vartostr(jStatus.Value) = 'ACCEPTED') then
      begin
        SQLExecute('delete from smsLogs where id = '+inttostr(j)+'');
      end else 
        ShowMessage('Status : '+vartostr(jStatus.Value));

      SData.Next;
    end;    
  finally
    SData.Free;
    sl.Free;
    slParam.Free;
  end;                 
end;

104

(72 replies, posted in General)

unforgettable wrote:

Thank you brain zaballa. I could not understand highlighted lines in these two pics attached. Can you tell some detail about them? Are these executable?

It is to compute for the receivable, deducting discount from sTotal.

105

(3 replies, posted in General)

I'm not sure to what you really need but this might give you an idea.

https://www.dropbox.com/s/74n585xw84u73 … a.zip?dl=1

106

(72 replies, posted in General)

unforgettable wrote:

Any one can tell how do we create trigger in attached project. In fact as data increase system takes time to load form have tablegrid. A trigger speeds up to load?

You haven't attached your project. I used the last attachment from my replies.

Well, trigger will help but in my opinion, if you aren't that familiar with trigger, then you study it first. There are other method to avoid the calculated fields(Most probably, this are the ones responsible in slowing your application). All you can do is just edit that calculated field (In this example the Sales_Ticket.sTotal) to a regular field(Currency in this case). Then handle the calculation in your code.

107

(1 replies, posted in General)

Did you ShowMessage that alert?

You might want to check this out Since the response is in JSON format I think. http://myvisualdatabase.com/forum/viewtopic.php?id=6329

108

(9 replies, posted in General)

v_pozidis wrote:

Hi all, I face a problem which is the following, I have added in my sqlite database new columns and new tables which in some cases are Related. How can I add from my old database the records to the new one using script code ? When I  copy the old sqlite database it crash in the folder of the program. So my idea was to fix a small program that will add in the  old sqlite database  the new columns and tables with the relations.  Or is there another way? In any case its a good time to learn how to convert our database with new tables and columns.
Please your help.

I'm thinking you already deployed your application to your client or you are using it.

I handle problem like this by saving a version number to the database (something like `settings`.`dbVersion`). Then, I created script to handle the alter queries. You need to carefully document each changes in your database

From the script.pas, I am indicating a CONST variable e.g.

CONST DBVER = 2; // this is the current version on the development database. I always change this manually on the dev database to avoid error when developing.

Then, executing the db revision checking on the begin end. area

procedure DBREVISION();
var currVer: Integer;
begin
    currVer := := SQLExecute('SELECT COALESCE(dbVersion, 0) AS currVer FROM settings WHERE 1 LIMIT 1');
    if currVer < DBVER then
    begin
        if DBVER < 1 then
        begin
            // alteration of the version 1
        end;
        if DBVER < 2 then
        begin
            // alteration of the version 2
        end;
        SQLExecute('UPDATE `settings` SET dbVersion='+IntToStr(DBVER));
    end;
end;

begin
    DBREVISION;
end.

I hope this can give you an idea on how handle your problem

I just check it out and trace back the problem. I was just lucky to spot it. smile Years of experience w/ MVD helps too.

Try changing the table for the query setting of the grid from newentry form and set it to customers

111

(1 replies, posted in General)

Did you try checking the KeyPreview Option? This enables me the Onkeypress on a form.

112

(3 replies, posted in General)

pdtonks77 wrote:

Hi there,
I have been using My Visual Database for a couple of years now on my windows laptop and got on well with it.
but now i have brought myself a macbook and just wondering if there is a way to run this software on there?

I think the only way for you to make it work is to make it dual boot or install windows on a virtualbox

113

(4 replies, posted in General)

k.krause wrote:

Hello,

I am looking for a formula for a calculated field that determines the age of a person from the difference between the date of birth and the current date. I tried a solution from Derek but his solution does not work with Mysql. Can someone help me?

Try this one

TIMESTAMPDIFF(YEAR, date_of_birth, CURDATE())

114

(30 replies, posted in General)

opercap wrote:
brian.zaballa wrote:
opercap wrote:

Only now i saw that you are the original sender of this message. My apologies.



Can you, please, send it to me too? It will be very usefull as i have an old users/password table wich i want to import to Role system.


Big Thanks

Best Regards

My email: classa@sapo.pt.

Sure, i'll send it to you


That would be amazing. Thanks a lot.

I already sent it. You can also refer to this topic

http://myvisualdatabase.com/forum/viewtopic.php?id=7915

115

(2 replies, posted in General)

If you are using the built in user-role functionality of MVD, then I think retrieving is not possible, however you can do something like setting new password using a secret question and answer. Here's my prototype for it.


User: admin
Pass: admin

116

(30 replies, posted in General)

opercap wrote:
brian.zaballa wrote:
gonpublic2k wrote:

Hi, could you e-mail me this please??

leggin2020@gmail.com

I'd appreciate it , thanks!!!

Sent.

Only now i saw that you are the original sender of this message. My apologies.



Can you, please, send it to me too? It will be very usefull as i have an old users/password table wich i want to import to Role system.


Big Thanks

Best Regards

My email: classa@sapo.pt.

Sure, i'll send it to you

117

(3 replies, posted in General)

sparrow wrote:

Hi brian.zaballa

In one project, I came across such a situation.
The checkbox mark is a dictionary on one of the tables, swapped JOIN in the query that built the MVD.
In your test case with an error (http://myvisualdatabase.com/forum/viewtopic.php?id=7339), specify
the check-dictionary on the "department" table. JOIN changes.
But replacing with a newer version has its advantages. 


The first time I saw the action of a checkbox. )

Oh, that solves the problem. Thank you for sharing. Checking Dictionary checkbox for the department solves the error. Kudos!

I'm using the latest(3.36.0) sqlite version on my MVD projects. Looking forward for the succeeding releases. Hoping they include UPDATE query alongside JOIN. smile

118

(3 replies, posted in General)

teco049 wrote:

Hello to all.


the included sqlite3.dll from MyVisualDatabase is from 2014.


In which folder can I place a newer version of this .dll that it will be copied to all compiled projects? After every compilation I get the old version back in the project folder.


An IT Newsletter has written that the newer versions of SQLITE have a speed improvement. More speed is a good thing.

You can put it under the installation folder of your MVD. In my case it is under "C:\Program Files (x86)\My Visual DataBase"


just make sure to have a backup of the current sqlite, you might run into an error when accessing 2 level of parent of a child in a report using the new version of sqlite. I hope you dont have this kind of record in your project/application. This error was not been fixed.

Here's my post with regards to the problem
http://myvisualdatabase.com/forum/viewtopic.php?id=7339

119

(13 replies, posted in General)

Can you elaborate your calculation?

120

(13 replies, posted in General)

Here's a workaround I've made in my project that act like numberbox. It doesn't have button thou.

Check your grid Settings, make sure you are not loading any data from it if you are using search button to load your data, vice versa. It's either you are missing a filed on Grid Settings or in the Search Button. Check it out and go back with OnChange of the grid.

Other possible cause, if you are sure your grid has no problem in field count, then check other grid, on your appliication, sometimes, copy-paste of grid will cause you error such as this when you didn't remove/change that OnChange event of the copied grid.

122

(5 replies, posted in FAQ)

rkpatro wrote:

I have purchased 4.x and 5.x .the license for both is also with me but but these old ver are not available .How can i download these pl help.

Here. I have the 5.5 version.
https://www.dropbox.com/s/nlita5g2w75w7 … 5.exe?dl=1

TNxNumberColumn will change the format displayed on the grid, you can put it in the OnChange Event of the grid.


To give you an idea, I've created and using a procedure(not with date thou but the idea is the same) in my projects that Format display of a field(a calculated one) into a money format

{
    Format Column in a Grid
    Called in onChange Event of a Grid

  FormatMoneyGrid(main.grdOR, 1);
}
procedure FormatMoneyGrid(TblGrid: TdbStringGridEx; column: integer; formatFooter:Boolean=True);
begin
    TNxNumberColumn(TblGrid.columns[column]).FormatMask := '#,##0.00';
    TblGrid.columns[column].Alignment := taRightJustify;
    if formatFooter then
        TblGrid.Columns[column].Footer.Caption := FormatFloat('#,###,##0.00', TblGrid.Columns[column].Footer.FormulaValue);
end;

Then I call it on Onchange event

procedure frmObligationToPay_grdOBWB_OnChange (Sender: TObject);
begin
    FormatMoneyGrid(frmObligationToPay.grdOBWB, 4, True);
end;

I'm using it when MVD didn't automatically formatting it on the grid. You might want to use it in the future when you are having trouble displaying calculated currency on the grid.:)

124

(6 replies, posted in Script)

daamoucheacil wrote:
brian.zaballa wrote:

Stock monitoring can be done in MVD. There are many way to achieve it.

You can elaborate more on what you are working on so that someone might help you.

I want to create a form to add orders and a form that contains a table that contains the quantity of goods in the store, the purchase price and the selling price. When adding an order to the customer, the quantity of the goods in stock, the purchase price and the selling price, and when saving the order, the quantity purchased by the customer automatically decreases from the store.  I apologize for the poor expression because I am not good at English

Again, there are many ways to do it.


For the purchase price and selling price, in my experience, saving this details will only give you estimated markup(when the price differ on your next stock or purchase transaction of the goods/item and the store has remaining stock of it). You don't want your application to check the quantity of each stock transaction you made and tag each sales/pullout of the item to where stock transaction you get it from.


If you are trying to compute exact income of the store, it is better to just have a cashflow module that will handle it.
Saving all expenses and sales/collections.


Then,
Income = Total(Sales/Collections) - Total(Expenses, this includes the purchase of the goods/stock basically).


Just charge your client on the additional module(cashflow). 3:)

125

(2 replies, posted in Script)

I'm not sure to what you are trying to do here but try changing

Form1.Button3.Click;

to

Form1.Edit4.Clear;
if Form1.ComboBox2.dbItemID > 0 then
    Form1.Edit4.Text := SQLExecute('SELECT Prixachat FROM PORTEGRIS WHERE id='+IntToStr(Form1.ComboBox2.dbItemID));