1 (edited by amsjunior1 2023-03-29 02:08:18)

Topic: trying to convert sqllite to mysql

I got an example right here on the forum very good. but i am having difficulty converting from sqllite to mysql

this is part of code.


  If Form1Button = 'Purchase Refund' then
    Begin
      //////////////////////////////////////////////////////////////////////////////////
      // Check to make sure that purchase refunds are not greater than the original purchase qty,
      //   This is checked when issuing a new refund on a purchase transaction.
      //////////////////////////////////////////////////////////////////////////////////
      PurchQtyVar := SqlExecute('Select Qty From PurchInv Where record_count = ' + Comprar_add.EditCounter1.Text + ' and id_DbCr = 3');
      TotRefundVar := SqlExecute('Select SUM(Qty) From PurchInv Where record_count = ' + Comprar_add.EditCounter1.Text
               + ' and id_DbCr = 5');

      If QtyVar + TotRefundVar > PurchQtyVar then
         Begin
            MessageBox('Refund qty will cause total refunds to be greater than the original purchase qty.','Error',MB_OK+MB_ICONERROR);
            Comprar_add.edPurchInvQty.SetFocus;
            Cancel := True;
            Exit;
         End;

error is.
could not convert variant of type (null) into type (integer)

this is line error
      TotRefundVar := SqlExecute('Select SUM(Qty) From PurchInv Where record_count = ' + Comprar_add.EditCounter1.Text
               + ' and id_DbCr = 5');

Post's attachments

Attachment icon Stock Level 2 DbCr Revised.zip 615.85 kb, 126 downloads since 2023-03-29 

2 (edited by sparrow 2023-03-29 06:32:40)

Re: trying to convert sqllite to mysql

SELECT COALESCE(SUM(Qty), 0)

and yet, if you use Form1.Edit1.Text then in the script it is ''' + Form1.Edit1.Text + ''' or ' + Form1.Edit1.sqlValue + '.
The same goes for other components.


Let's start reading the MVD instruction.

http://myvisualdatabase.com/help_en/script_edit.html

3 (edited by amsjunior1 2023-03-29 15:34:48)

Re: trying to convert sqllite to mysql

thank you my friend, it worked perfect.