I'd prefer to keep the connection open all the time but just in case I somewhere previously had issued
Code: Select all
MyConnection1.Close;
Code: Select all
MyQuery.Close;
MyQuery.SQL.Clear;
MyQuery.SQL.Add(sql);
MyQuery.Open;
...
MyQuery.Close;
or must I say
Code: Select all
MyQuery.Close;
MyQuery.SQL.Clear;
MyQuery.SQL.Add(sql);
MyConnection1.Open; // <-------------
MyQuery.Open;
...
MyQuery.Close;
MyConnection1.Close;
Code: Select all
DatabaseConnectionState := MyConnection1.Connected; //remember state
MyQuery.Close;
MyQuery.SQL.Clear;
MyQuery.SQL.Add(sql);
MyConnection1.Open; // <-------------
MyQuery.Open;
....
MyQuery.Close;
MyConnection1.Connected := DatabaseConnectionState;