1 Attachment(s)
Concurrent database access and QDataWidgetMapper?
Hello,
i have two database questions:
1.) Each user should sees a consistent view of the data. What have i to do
if two or more user have simultaneously access to my database?
2.) What are the right classes to set a QDataWidgetMapper for my database?
I have try to use QSqlTableModel, but the problem is, one dataset can include
data fom the table "Experiment", "Temperatur" and "Qualities". How can i get
a Model for the QDataWidgetMapper to handle this?
Attachment 9838
Code:
model->setTable("Temperatur");
model
->setFilter
("ExperimentID=" + QString::number(ID
));
model->select();
mapper->setModel(model);
mapper->addMapping(min, model->fieldIndex("min"));
mapper->addMapping(max, model->fieldIndex("max"));
mapper->toFirst();
Code:
CREATE TABLE [Experiment]
(
[ExperimentID] integer NOT NULL PRIMARY KEY AUTOINCREMENT,
[Name] varchar (100) NOT NULL,
[Date] datetime NOT NULL DEFAULT '0000-00-00'
);
CREATE TABLE [Temperatur]
(
[ExperimentID] integer NOT NULL DEFAULT 0,
[min] integer DEFAULT 0,
[max] integer DEFAULT 0,
[average] integer DEFAULT 0,
...
);
CREATE TABLE[Qualities]
(
[ExperimentID] integer NOT NULL DEFAULT 0,
[material] integer DEFAULT 0,
[fuel] integer DEFAULT 0,
[container] integer DEFAULT 0,
...
);
Re: Concurrent database access and QDataWidgetMapper?
Quote:
Originally Posted by
cyberduck
1.) Each user should sees a consistent view of the data. What have i to do
if two or more user have simultaneously access to my database?
You could poll the database for changes or use an out-of-band communication mechanism to notify other clients when changes have been made
Quote:
Originally Posted by
cyberduck
2.) What are the right classes to set a QDataWidgetMapper for my database?
I have try to use QSqlTableModel, but the problem is, one dataset can include
data fom the table "Experiment", "Temperatur" and "Qualities". How can i get
a Model for the QDataWidgetMapper to handle this?
Using QSqlQueryModel with a query that gets the necessary data from all involved tables?
Cheers,
_
Re: Concurrent database access and QDataWidgetMapper?
Hi,
thank you for the reply.
So far so good, i got a QSqlRecord from the QSqlQueryModel, but i cant write it back!
The QSqlQueryModel is read-only and i want change or insert data into the database. How can i do that?
Can you help me please?