Solved

Dataset not in insert or edit mode

Posted on 2001-08-26
6
1,872 Views
Last Modified: 2012-05-04
Here come some easy points to earn.

I have three tables, table1, table2 and table3.
Table2 have table1 as master.
Table3 is connected to the same database table as table1. I use table3 to look up information from the same database as table1 to add to table2.

Fields in table1 are:
ArtNo
Name

Fields in table2 are:
ArtNo
Pos
SubArtNo

My issue is to insert data from table1 into table2 in order to create a data structure.
The strange thing is that I recive a run time error when executing "Table2.Insert". The message is "Datasource is not in Insert or Edit mode".
How can I recive that message when puting the table in Insert mode??

Thanks in advance for your help.
0
Comment
Question by:dikonsult
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:God_Ares
ID: 6427196
db.Insert; //turns some sort of switch
db.Fields.Fields[1].AsInteger := Finteger;
db.Fields.Fields[2].AsString := Fstring;
db.Post;
//No further comments
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6427637
guessing you have table2 pushed in the edit-mode with table2.insert, but you will modify the table1.fields

review your code
0
 

Author Comment

by:dikonsult
ID: 6427895
Kretzschmar,
nothing much about the code, quite similar to what God Ares proposed as an answer !!

procedure TFormMain.BitBtn3Click(Sender: TObject);
var
   i:integer;
begin
with Datamodule2 do
begin
  i:=Table2.RecordCount+1;
  Table2.Insert;
  Table2Pos.AsInteger:=i;
  Table2SubArtNo.Value:=Table3ArtNr.Value;
  Table2.Post;
end;
end;

Table2.Mastersource = Table1Datasource with masterFields = ArtNo.
Table3 is connected to the same TableName as Table1.

The error message comes at the line TableStrukreg.Insert.

The funny thing is that a new record actually is created in the table but my values are not added only the connection value ArtNo wich it recives from table1.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 6427931
are there more ttable instances named table2?

maybe this change resolves the problem

 i:=Datamodule2.Table2.RecordCount+1;
 Datamodule2.Table2.Insert;
 Datamodule2.Table2.FieldByName('Pos').AsInteger:=i;
 Datamodule2.Table2.FieldByName('SubArtNo').Value:=Table3ArtNr.Value;
 Datamodule2.Table2.Post;

0
 

Author Comment

by:dikonsult
ID: 6428012
No kretschmar it did not help.
But now in pure desperation I removed the tables and created them again with same names and same connections. Suddenly it worked ????
Please send me an answer and you will recive the points as the one really trying.

Regards
dikonsult
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 6428032
well,

then i guess,
there was something mixed with the persistent fields, maybe

glad that you get it work,
even if i was not a real help,
which pointed out the problem

meikl ;-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question