<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi all,
<br>
<blockquote cite="mid:51B06CF4.7010105@metropolitancollege.co.za"
type="cite">
<br>
I tried reviewed the code and commented the try...except statement
for more debug:
<br>
<br>
procedure TfrmMainWindow.bitBtn1Click(Sender: TObject);
<br>
begin
<br>
//try
<br>
DataModuleConn.openConnection;
<br>
DataModuleConn.MySQL55Conn.Transaction :=
DataModuleConn.SQLTransaction;
<br>
//DataModuleConn.MySQL55Conn.Transaction.Active:=False;
<br>
DataModuleConn.SQLTransaction.DataBase:=DataModuleConn.MySQL55Conn;
<br>
DataModuleConn.SQLQuery.DataBase:=DataModuleConn.MySQL55Conn;
<br>
DataModuleConn.SQLQuery.Transaction:=DataModuleConn.SQLTransaction;
<br>
DataModuleConn.SQLQuery.Active:=False;
<br>
DataModuleConn.SQLQuery.SQL.Text:='';
<br>
DataModuleConn.Datasource.DataSet:=DataModuleConn.SQLQuery;
<br>
DataModuleConn.Datasource.DataSet.Active:=False;
<br>
//DBGrid1.DataSource.DataSet.Active:=False;
<br>
DBGrid1.DataSource:=DataModuleConn.Datasource;
<br>
DBNavigator.DataSource:=DataModuleConn.Datasource;
<br>
<br>
if DataModuleConn.MySQL55Conn.Connected=True then begin
<br>
frmMainWindow.memReports.Append(msgOpeningDB);
<br>
frmMainWindow.memReports.Append(msgDBReady);
<br>
end;
<br>
<br>
if (cbbList1.Items[cbbList1.ItemIndex] = 'ALL') then begin
<br>
DataModuleConn.SQLQuery.SQL.Text:='SELECT gender, year,
country FROM reiser';
<br>
end
<br>
<br>
else if (cbbList1.Items[cbbList1.ItemIndex] = lisCountry1)
then begin
<br>
DataModuleConn.SQLQuery.SQL.Text:='SELECT gender, year,
country FROM reiser WHERE country = ''Dutch Republic''';
<br>
end
<br>
else //(cbbList1.Items[cbbList1.ItemIndex] = lisCountry3)
<br>
begin
<br>
DataModuleConn.SQLQuery.SQL.Text:='SELECT gender, year,
country FROM reiser WHERE country = ''Holland''';
<br>
end;
<br>
<br>
//DataModuleConn.SQLTransaction.StartTransaction;
<br>
DataModuleConn.SQLQuery.Close;
<br>
DataModuleConn.Datasource.DataSet.Active:=True;
<br>
DataModuleConn.SQLQuery.Open;
<br>
<br>
//except
<br>
// frmMainWindow.memReports.Append(ErrConnectionFailed);
<br>
//end;
<br>
end;
<br>
<br>
The first trigged for the procedure bitBtn1Click1 works fine, the
second trigged give up, with the above error:
<br>
<br>
Operation cannot be performed on an active dataset.
<br>
</blockquote>
Could you point out which line generates the error ?<br>
As a matter of fact, there are too much DB related operations.<br>
For instance the first 9 lines after the one // Try should be moved
somewhere in an independent method and called only once in some
intialization routine.<br>
Secondly, the two next lines do exactle the same thing, only one of
them should be removed<br>
DataModuleConn.Datasource.DataSet.Active:=True; <====
keep this one as more datasource independent<br>
DataModuleConn.SQLQuery.Open;
<---------- this one can be removed<br>
<br>
This rearrangement should work provided the 9 preceeding lines have
been moved somewhere else and executed at least once<br>
<br>
if DataModuleConn.SQLQuery.Active then<br>
DataModuleConn.SQLQuery.Close;
<br>
if DataModuleConn.MySQL55Conn.Transaction.InTransaction then<br>
DataModuleConn.MySQL55Conn.Transaction.Commit;<br>
if DataModuleConn.MySQL55Conn.Connected=True then begin
<br>
frmMainWindow.memReports.Append(msgOpeningDB);
<br>
frmMainWindow.memReports.Append(msgDBReady);
<br>
end;
<br>
<br>
if (cbbList1.Items[cbbList1.ItemIndex] = 'ALL') then begin
<br>
DataModuleConn.SQLQuery.SQL.Text:='SELECT gender, year,
country FROM reiser';
<br>
end
<br>
<br>
else if (cbbList1.Items[cbbList1.ItemIndex] = lisCountry1)
then begin
<br>
DataModuleConn.SQLQuery.SQL.Text:='SELECT gender, year,
country FROM reiser WHERE country = ''Dutch Republic''';
<br>
end
<br>
else //(cbbList1.Items[cbbList1.ItemIndex] = lisCountry3)
<br>
begin
<br>
DataModuleConn.SQLQuery.SQL.Text:='SELECT gender, year,
country FROM reiser WHERE country = ''Holland''';
<br>
end;
<br>
<br>
DataModuleConn.SQLTransaction.StartTransaction;
<br>
DataModuleConn.SQLQuery.Open;
<br>
<br>
Antonio.<br>
<blockquote cite="mid:51B06CF4.7010105@metropolitancollege.co.za"
type="cite">Press OK to ignore and risk data corruption.
<br>
Press Cancel to kill the program.
<br>
<br>
I tried to close and open the Dataset on my procedure
bitBtn1Click1.
<br>
<br>
May you please assist me?
<br>
<br>
<blockquote type="cite">
<br>
<br>
-- <br>
_______________________________________________
<br>
Lazarus mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a>
<br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<table
style="font-family:'Calibri','sans-serif';font-size:8.0pt;color:#002f87;border:0;width:auto;">
<tbody>
<tr>
<td style="vertical-align:bottom;padding:40px 20px
25px;border-top:1pt solid #BFBFBF;"> <img alt="Sita
Software"
src="cid:part1.04070906.03050803@sitasoftware.lu"> </td>
</tr>
<tr>
<td style="vertical-align: top; padding: 5px 20px 0;"> <b>Antonio
Fortuny</b><br>
Senior Software engineer<br>
<br>
220, avenue de la Liberté<br>
L-4602 Niederkorn<br>
Tel.: +352 58 00 93 - 93<br>
<a style="color:#002f87;cursor:pointer;text-decoration:
none;" href="http://www.sitasoftware.lu">www.sitasoftware.lu</a><br>
</td>
</tr>
<tr>
<td style="padding:20px 20px 30px;border-bottom: 1pt solid
#BFBFBF;" align="right"> <img alt="Your IT Partner"
src="cid:part3.00000103.04060800@sitasoftware.lu"> </td>
</tr>
</tbody>
</table>
</div>
</body>
</html>