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
How to open TMSQuery without issuing SELECT
-
- Posts: 4
- Joined: Thu 01 Nov 2018 15:14
Re: How to open TMSQuery without issuing SELECT
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.
So that we can give a more specific answer, describe the problem in more detail.
-
- Posts: 4
- Joined: Thu 01 Nov 2018 15:14
Re: How to open TMSQuery without issuing SELECT
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
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;
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;
-
- Posts: 4
- Joined: Thu 01 Nov 2018 15:14
Re: How to open TMSQuery without issuing SELECT
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
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.