Le 04/06/2013 16:54, Eric Kom a écrit :
On 04/06/2013 10:19, Antonio Fortuny wrote:

Thanks, I did changed to Commit and then caNone before it solved the error, another error message pop up saying Access Violation. Anyway, the problem was solved.

The above code its giving me a problem; the SQLQuery do not changed according to the condition for exemple if the first condition matched, the second condition is still going to use the matching from the first and vice versa.

else if (cbbList.Items[cbbList.ItemIndex] = lisList1) then begin
              DataModuleConn.SQLTransaction1.Active:=True;
Use DataModuleConn.SQLTransaction1.StartTransaction instead, it is more readable ans standard Also, if you commit or rollback the transaction most of the DataSet based components close their datasets as well. This means that the original transaction must be InTransaction for the grid to display the collected data. The transaction can be shared by all DataSet descendants though.
DataModuleConn.SQLQuery1.SQL.Text:='SELECT year, country, gender FROM reiser WHERE country = ''Dutch Republic''';
DBGrid1.DataSource.DataSet:=DataModuleConn.SQLQuery1;
              DBGrid1.DataSource:=DataModuleConn.Datasource;
              DBGrid1.DataSource.DataSet.Active:=True;
              //DataModuleConn.SQLTransaction1.Commit;
              DataModuleConn.SQLTransaction1.CommitRetaining;
         end
else if (cbbList.Items[cbbList.ItemIndex] = lisList1) then begin
              DataModuleConn.SQLTransaction1.Active:=True;
DataModuleConn.SQLQuery1.SQL.Text:='SELECT year, country, gender FROM reiser WHERE country = ''Holland''';
DBGrid1.DataSource.DataSet:=DataModuleConn.SQLQuery1;
              DBGrid1.DataSource:=DataModuleConn.Datasource;
              DBGrid1.DataSource.DataSet.Active:=True;
              //DataModuleConn.SQLTransaction1.Commit;
              DataModuleConn.SQLTransaction1.CommitRetaining;
         end;

I have tried DataModuleConn.SQLTransaction1.Rollback also, still the same.

Antonio.


--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus






--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to