?
Solved

Dataset not in insert or edit mode

Posted on 2001-08-26
6
Medium Priority
?
1,924 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 200 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

770 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