Solved

Dataset not in insert or edit mode

Posted on 2001-08-26
6
1,902 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
Industry Leaders: 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

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!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

690 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