Solved

Dataset not in insert or edit mode

Posted on 2001-08-26
6
1,848 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now