dlucic 1 Posted October 8 I have simple DataSnap server application with connection to MS SQL Server and also simple client application. On the server side I have TFDConnection object to connect to MS SQL Server. I also have TFDQuery with simple sql "insert into slika_test (slika) values (:slika)". Param slika is for image datatype in table test_slika. This is properties of Param slika of TFDQuery object Of course, there is DataSetProvider object On the client side I have TSQLConnection and DSProviderConnection object's. I connect to DataSnap server application with them. There is also TClientDataSet object This is code for click on Button I load image from Image1 object on the form into MemoryStream. Than I put that MemoryStream in Param of ClientDataSet object and execute. When I do that for the first time everything goes well. Data is stored in MS SQL table. But when I click it another time and same code executes I receive this error on the server application Any body knows what is the problem? Share this post Link to post
Remy Lebeau 1392 Posted October 8 3 hours ago, dlucic said: You are not resetting ms.Position=0 before calling Param.LoadFromStream(). You are also leaking the TMemoryStream. Share this post Link to post
dlucic 1 Posted October 9 16 hours ago, Remy Lebeau said: You are not resetting ms.Position=0 before calling Param.LoadFromStream(). You are also leaking the TMemoryStream. Thank you bu that is not my problem. I changed code as you tell me but I still have this massage Share this post Link to post
Cristian Peța 103 Posted October 9 I would debug that TestDS server and see where the error occurs. Share this post Link to post
dlucic 1 Posted October 9 Thanks again. If you wish I can send you compleate code for both applications. That is small peace of code for each of them. But you need a small MS SQL Database with one table with just to columns Share this post Link to post
Jirka52 2 Posted October 9 What I see, that you want to put some image into SQL "insert" command. If I try to save some blob, I every time use dataset field and call TClientdataset.ApplyUpdates. Example: //you wan to create new record therefore append dodajslikujds.append; try dodajslikujds.Fieldsbyname('here put correct fieldname').loadFromstream(ms); dodajslikujds.Post; var I := dodajslikujds.ApplyUpdates(0); if (I <> 0) then begin raise Exception.Create('Data was not saved!'); end; {if} except dodajslikujds.Cancelupdates; raise; end; Share this post Link to post
dlucic 1 Posted October 9 1 hour ago, Jirka52 said: What I see, that you want to put some image into SQL "insert" command. If I try to save some blob, I every time use dataset field and call TClientdataset.ApplyUpdates. Example: //you wan to create new record therefore append dodajslikujds.append; try dodajslikujds.Fieldsbyname('here put correct fieldname').loadFromstream(ms); dodajslikujds.Post; var I := dodajslikujds.ApplyUpdates(0); if (I <> 0) then begin raise Exception.Create('Data was not saved!'); end; {if} except dodajslikujds.Cancelupdates; raise; end; Thank you, it works fine now. Share this post Link to post