Page 1 of 1

Refreshing field information after database change

Posted: Fri 23 Sep 2016 10:53
by dupe
In our application we are switching database connections during runtime.
Each database uses the same view but with different columns.
If we change the database from the connection during runtime the TMSQuery keeps all the field information of the old database.
This is a problem because every view in each database has additional or different field informations.

Code: Select all

connection.Database := 'Database1';
query.Connection := connection;
query.SQL.Text := 'SELECT * FROM View';
query.Open;
query.Close;
connection.Database := 'Database2';
query.Open; // <- Query has already fields of Database1 View
How do we refresh all the field informations?

Thanks in advance

Re: Refreshing field information after database change

Posted: Sat 24 Sep 2016 17:41
by paweld

Code: Select all

connection.Database := 'Database1';
query.Connection := connection;
query.SQL.Text := 'SELECT * FROM View';
query.Open;
query.Close;
connection.Database := 'Database2';
query.Fields.Clear;
query.Open;