Jump to content

limelect

Members
  • Content Count

    775
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by limelect


  1. The program does not matter but basically, it shows database data

    by using  FDConnection1.GetTableNames('', '', '', str, [osMy, osOther], [tkTable],    False);

    and      FDConnection1.GetFieldNames('', '', str, '', Str2);

    Now to the story

    I got back to this program (that worked) compiled and it stopped working..

    I did nothing just compiled.

    worked on it nothing.  went to my backup and copied the main.pas and main.dfm

    (those are the only files) did not work. .

    The execution on the backup workers as expected.

    Mad a new project by copping from backup the dpr pas dfm and compile

    it does not work.

    Now to the NOBEL prize.

    Copy the project from the backup to a directory and compile and it works

    Check by comparing pas and dfm. same.

    Check as much as possible DCU with hex program same.

    size wise both exe are the same.

     

    The point is that it is so crazy that I had to share it with you guys.

     


  2. I own Delphi 10.2.3 with a license

    why I do not have 

     FireDAC.Phys.MSSQL and more.?

    All I have is in the picture

    Screenshot - 26_09_2023 , 11_24_30.jpg

    Is it only in enterprise Not in professional?

     

     

     


  3. @fr0st

     

    The first suggestion did not help lock.

    The unique suggestion seems to work but

    catching the error seems not to stop the window message;

    For a moment it enters data into DBGRID until I cancel

    1. I do not want the Windows error messages only mine

    2. If possible not create the record but that is not important

        as the cancel will delete it.

    #1 is the most important.

     

    procedure TForm1.FDTable1Error(ASender, AInitiator: TObject; var AException:
        Exception);
    begin
    MessageDlg('err1', mtWarning, [mbOK], 0);
    FDTable1.Cancel;
    end;

     

     

    procedure TForm1.FDTable1PostError(DataSet: TDataSet; E: EDatabaseError; var
        Action: TDataAction);
    begin
      MessageDlg('err2', mtWarning, [mbOK], 0);
    FDTable1.Cancel;

    end;
     

     


  4. I have TDBEdit.

    I entered a number and would like to know BEFORE POST

    if the number exists in the database and cancels the post.

    If OK (number does not exist ) the POST  is executed Now it gives a LOCK condition.

    What I tried

     

    procedure TForm1.FDTable1BeforePost(DataSet: TDataSet);
    begin

     Form1.FDQuery1.SQL.Clear;
      Form1.FDQuery1.SQL.add('Select *');
      Form1.FDQuery1.SQL.add('from WeighingCows');
      Form1.FdQuery1.SQL.add('WHERE Cownumber = :Cownumber');
      Form1.FDQuery1.ParamByName('Cownumber').AsString := Drivers.DBEdit1.Text;
      Form1.FDQuery1.Open;
      if Form1.FDQuery1.RecordCount > 0 then
      begin
       MessageDlg('This number exist', mtError, [mbOK], 0);
      FDTable1.Cancel;<<<<<<<<<<< if execute then OK 
      end;
      Form1.FDQuery1.Close;
     end;
     I got a LOCK condition.

    It seems I am not allowed to use SQL and table at the same time.

     

    I also tried  FDTable1.CachedUpdates is true but then

    Form1.FDTable1.ApplyUpdates() ; gave LOCK too.

    Any help?

     

    P.S I tried that too

    //Form1.FDQuery1.Connection:=nil;
    //Form1.FDTable1.ApplyUpdates() ;
    //Form1.FDQuery1.Connection:=Form1.FDConnection1;
     

     

     


  5. 13 hours ago, Remy Lebeau said:

    Better to just use the TIdContext objects instead, since they are already unique.

    Just for knowledge. How will you save TIdContext and then interrogate the list?

    In my case, I use a stringlist with peernumber=worker# it is very

    helpful to search for peernumber. or vice versa.

    clients.IndexOfName(IntToStr(PeerPort)); in one case. or vice-versa.

    P.S. I do not suspect using outside the network of the project.


  6. To clarify the application

    The client is a worker. He has a number in the server DB.

    Connection is done when the worker send his ID=DB number

    and get needed information from server.

    The exchange is very simple.

    Obviusly the server gets worker number and associate the peerport to it.

    I get all kind of messeges for worker where he get data from DB in the server.


  7. 7 hours ago, mjustin said:

    With Indy, the recommended way to send a message to a specific client is to assign an unique client id

    I think i do not understand.

    The peerport is assigned AFTER connection. An ID? where is it. Do you know it

    before connection.Does it equel peerport so it is the same.

    In my techinc LIST has all necesery information to identify the client.

    PeerPort changes every time you reconnect to server and is not fixed.

    Further more in the SERVER I associate user to peerport of the client so I know 

    who is using the client.

    In the IdTCPServer1Execute I know who is connected as I send info from client to server

    So what is left to do is pick the right info from my LIST port=user and sent what ever to port.


  8. I have a nice solution You can send any string to any client

    This is just the general idea and someone mite use this

    On the client put the timer

    procedure TForm1.Timer1Timer(Sender: TObject);
    var
    s: string;
    begin
    if not IdTCPClient1.Connected then Exit;
    if IdTCPClient1.IOHandler.InputBufferIsEmpty then Exit;
    s := IdTCPClient1.IOHandler.InputBufferAsString;
    Memo1.Lines.Add('Received: ' + s);

    end;
     

    On the server Use the list

     

    procedure TForm2.Button2Click(Sender: TObject);
    var
    List: TList;
    T:TStringList;
    i:Integer;
    begin
     T:=TStringList.Create;
     t.Add('1234');
      List := IdTCPServer1.Contexts.LockList;
      TIdContext(List.Items[0]).Connection.WriteRFCStrings(t);
      IdTCPServer1.Contexts.UnlockList;
      t.Free;
    end;
     

    Keep the client list List.Items[0]<< 1 2 3 4 and so on

    It needs more work but it works This is a general idea;

    I added listview with the client list and used it

    And it works nicely.

     

    TIdContext(List.Items[StrToInt( ListView1.Selected.Caption)]).Connection.WriteRFCStrings(t);
     

     

     


  9. I need just advice.  I have no problems.

    I have IdTCPServer IdTCPClient with more than one client.

    I am using the server as a response to clients.

    However, I would like to send specific client information from the server, which is impossible.

    However, I saw a TIMER answer which I liked at the end of

    https://stackoverflow.com/questions/5530038/how-to-handle-received-data-in-the-tcpclient-delphi-indy

     

    Here comes the knowledge. If the server sends a message to whom does he send it? To all clients? Or else?

    The server message is not a response to the client message.

    I could not find a write instruction with the peer number.

    As I have the PeerPort   on my server software (I keep a list) 

    I suspect it is not possible to send from server text to a specific Client.

    A solution is to embed in the message a sign that a specific client will recognize.

    Any other solution in your opinion?

     

     


  10. @Remy Lebeau First thanks.

    3 hours ago, Remy Lebeau said:

    Which UDP components, exactly? Indy's?  Someone else's?  Please be more specific.

    Indy's.

     

    3 hours ago, Remy Lebeau said:

    Please show your actual code on both sides.

    It is so simple

    UDPClient.Send('#2');

    server response

             mytext := StringToBytes(s);
              UDPServer.SendBuffer(ABinding.PeerIP, ABinding.PeerPort, mytext);

    3 hours ago, Remy Lebeau said:

    The only way that makes sense is if the server is actually sending a $00 byte,

    I am profesional to exclude that. checking with a brp on the server 

    and seeing the problem in the client

     

    Most of the time strings are very short.

    But in that case, the string is a bit longer like maybe 100 characters.

    And I expect to receive even longer strings.

     

    It seems something within the receiver (client) as 

    The server works perfectly.

     

    If things are not  stable I will move to a different communication

     

     


  11. @Remy Lebeau First thanks.

    2 hours ago, Remy Lebeau said:

    Which UDP components, exactly? Indy's?  Someone else's?  Please be more specific.

    Indy's.

     

    2 hours ago, Remy Lebeau said:

    Please show your actual code on both sides.

    It is so simple

    UDPClient.Send('#2');

    server response

             mytext := StringToBytes(s);
              UDPServer.SendBuffer(ABinding.PeerIP, ABinding.PeerPort, mytext);

    2 hours ago, Remy Lebeau said:

    The only way that makes sense is if the server is actually sending a $00 byte,

    I am profesional to exclude that. checking with a brp on the server 

    and seeing the problem in the client

     

    Most of the time strings are very short.

    But in that case, the string is a bit longer like maybe 100 characters.

    And I expect to receive even longer strings.

     

    It seems something within the receiver (client) as 

    The server works perfectly.

     

     


  12. I have a software solution but I want to understand and have

    a nicer fix.

    I have UDPClient and UDPServer

    I receive a text from the server with a press of a button on the client.

    If I press once I get the text OK Second time I get Zero in the buffer.

    I made sure that the server sends the text every time.

    So I made a stupid fix that works perfectly.

     

       UDPClient.ReceiveBuffer(Buf);
       if buf[0]=0 then
        UDPClient.ReceiveBuffer(Buf);

     

    Any idea why it happens
    I read a question about resetting the client buffer.

    Further, if I delete the connection and reconnect it works.

    But I am not allowed to do so as the connection has to stay with

    the right peer number.

     


  13. First thank you, everybody.

    Second, now it works.

    Why? This one up there knows.

    I started everything all over slowly checking every step.

    Did the same thing (?) again.

    That is our profession's frustration and then success.

    P.S. Once in a while return to D7 (old projects) and the report works without any glitches.

×