Every time I execute a query (Place, Remove,UPDATE). After Should i do Choose * From Table, so my info is visible around the Power grid control?
UniQuery1 is my dataset. I am utilizing a TDBADvListView control.
UniQuery1.Close; UniQuery1.SQL.Clear; SQL_QUERY:= 'insert into ListaCamiones(Tablilla,Marca,Modelo,Color) Values (' +QuotedStr(a1)+','+ QuotedStr(a2)+','+ QuotedStr(a3)+','+ QuotedStr(a4)+')'; UniQuery1.SQL.Text := SQL_QUERY; UniQuery1.Execute;
Should i do, Choose * From ListaCamiones In order to begin to see the information back on my small TDBADvListView?
The reply is both it depends!
Yes for the reason that you have to execute a Choose query again to be able to aggregate the modified recordset, no for the reason that it's not necessary to carry out the query like a separate execution.
Should you append a semicolon in the finish of the Place/UPDATE/Remove query string, and immediately follow that through the preferred Choose query, your call to complete will simultainiously update the records and aggregate the up-to-date recordset for display.
Furthermore, I'd alter the way you are building your SQL string too!
const INSERT_QUERY_STRING = 'INSERT INTO ListaCaminoes(Tablilla, Marca, Modelo, Color) VALUES ("%s", "%s", "%s", "%s"); SELECT * FROM ListaCaminoes'; // Now inside your method UniQuery1.SQL.Text := Format(INSERT_QUERY_STRING, [a1, a2, a3, a4]); UniQuery1.Execute;
Hope it will help!
Generally, yes, because in my opinion whenever you make database changes via SQL claims:
- no database component instantly refreshes the query,
- no database can refresh the information inside your application once the data has transformed within the database.
I suggest that you employ another query component (UniQuery2) to complete your SQL statement. The you should use the ReQuery approach to your Query to re-execute your original query (UniQuery1). With respect to the database components you're using, the local cursor might be totally reset.
Alternately you are able to Append/Place to include records and Edit to alter records of UniQuery1. This eliminates the necessity to re-execute your original query since the changes are put into the dataset records buffered in your area through the Query component. But, re-performing the totally essential to get records which were added/edited by other customers as your query was last performed.
Should you just placed the data towards the Database you've first got it already!
In certain SQL-Variants (in mySQL I'm shure) you could have the command "place_id()" in the API, that returns the car_INCREMENT - worth of the final placed Dataset.
If you want to understand this ID, it's what you want (on mySQL, like I stated), but when you need to produce other data you need to Query it again. Inside a combined query (like published before) or perhaps in two seperate queries.
Glad to assist!