Page 1 of 1

How to open TMSQuery without issuing SELECT

Posted: Wed 20 Feb 2019 09:32
by AntonPlotnikov2018
Hello.

Is there an ability to open a TMSQuery without issuing of a SELECT SQL? My dataset is intended to insert new items in cached update mode and there is nothing to select from database.

Wbr,
Anton

Re: How to open TMSQuery without issuing SELECT

Posted: Fri 22 Feb 2019 14:28
by Stellar
We do not quite understand the essence of your question.
So that we can give a more specific answer, describe the problem in more detail.

Re: How to open TMSQuery without issuing SELECT

Posted: Mon 04 Mar 2019 07:00
by AntonPlotnikov2018
I have a form for a document editing. There are two datasets placed In this form: for a document head and for a document content. When I insert new document both datasets have to be opened. And there are two select statements are issued during opening of the datasets. But for the insert mode there is no reason to issue a select statetment, because I want to insert records in datasets then commit them to database. So, a select is excessive and needs a database connection when it is not appropriate

Re: How to open TMSQuery without issuing SELECT

Posted: Wed 06 Mar 2019 11:33
by Stellar
To add records to a table, you can execute an SQL expression with help of the Execute method. For example:
MSQuery1.SQL.Text := 'INSERT INTO Dept (DName) VALUES (''New'')';
MSQuery1.Execute;

You can also try executing a query on the server which predeterminedly does not return results. For example:
MSQuery1.SQL.Text := ' SELECT * FROM Dept WHERE 1=0 ';
MSQuery1.Open;

Re: How to open TMSQuery without issuing SELECT

Posted: Tue 02 Apr 2019 07:47
by AntonPlotnikov2018
I don't want to issue a SELECT statement In some cases. Look at the .NET DataSet. I can start to use it for data inserting without database connection. A user inputs data to it. Then he presses Save button, and all data saves on the SQL Server. So there is a single query to database. On the other hand, with SDAC there will be at least two query to database. And the first of them is excessive and requires a database connection at the beginning of editing, not at the saving.

Re: How to open TMSQuery without issuing SELECT

Posted: Thu 04 Apr 2019 14:17
by Stellar
Unfortunately, SDAC does not allow the addition of records when the dataset is inactive. This behaviour comes from the fact that TMSQuery and TMSTable inherit from TDataSet. Adding and updating data in the dataset can be achieved through the standard means.