Page 1 of 1

Operator problems with MyDAC for Delphi

Posted: Wed 07 May 2008 03:45
by Ddoo
I do not have a lot of background with database SQL.

I am using a purchased copy of this software, Win XP, MySQL database

When I select a table, then a cellID eg. ProjectID=1 , then bselect a Member = B1, then add data to a table and save it all is well.

If I then select the following Same ProjectID New Member below.

MySQLQuery4.Close;
MySQLQuery4.SQL.Clear;
MySQLQuery4.SQL.Add('SELECT * FROM projectboq where ProjectID = ' + edtQuoteNo.Text + ' AND ' +
'EngMark =''' + edtEngMark.Text + ''';');
MySQLQuery4.ExecSQL;
MySQLQuery4.Active := True;

The new record in the table is selected! All appears OK. ProjectID=1, Member = B2

Here is my problem....
ProjectID=1 and member = B2, then add data to a table and saved, the data is saved in the first record, that is Member=B1

MySQLTable4.Edit;
MySQLTable4.FieldByName('ProjectID').AsInteger := StrToInt(edtQuoteNo.Text);
MySQLTable4.FieldByName('Zone').AsString := edtSelectZone.Text;
MySQLTable4.FieldByName('EngMark').AsString := edtEngMark.Text;
MySQLTable4.Post;


This is driving me mad and it must be my stupid error. Help please. :(

Posted: Wed 07 May 2008 04:08
by tltmusashi
just do this:

Code: Select all

MySQLTable4.FieldByName('ProjectID').Value := edtQuoteNo.Text; 
MySQLTable4.FieldByName('Zone').Value := edtSelectZone.Text; 
MySQLTable4.FieldByName('EngMark').Value := edtEngMark.Text; 
MySQLTable4.Post();

Posted: Wed 07 May 2008 05:24
by Ddoo
Thanks for youyr reply.
I have done that. That is why I am so puzzled.

//Extract from code......
MySQLTable1.Edit;
MySQLTable1.FieldByName('ProjectID').AsInteger := StrToInt(edtJobNo.Text);

MySQLTable1.FieldByName('EngMark').AsString := edtMarkNo.Text;

// Purchasing
MySQLTable1.FieldByName('FabDateIssue').AsDateTime := StrToDate(edtFabDate.Text);
........
.......
MySQLTable1.Post;

Done that!

It isn't the same though.. What is the .value that is:

MySQLTable1.FieldByName('EngMark').VALUE := edtMarkNo.Text;

Thanks in anticipation.

Posted: Wed 07 May 2008 07:02
by Ddoo
Obviously that is for using variant values. The others, that is ".AsString" shouldn't make any difference.

Posted: Wed 07 May 2008 20:17
by Ddoo
tltmusashi wrote:just do this:

Code: Select all

MySQLTable4.FieldByName('ProjectID').Value := edtQuoteNo.Text; 
MySQLTable4.FieldByName('Zone').Value := edtSelectZone.Text; 
MySQLTable4.FieldByName('EngMark').Value := edtEngMark.Text; 
MySQLTable4.Post();
Thanks for that. Yes that is how I am doing that also.

Problem. :?:
Why is it still writing to the first record always "B1" when the record selected and showing is actually B2. Even if I haven't previously called B1.

Note: I am using the "Edit-post" as shown previously. Is that OK? :?

Posted: Thu 08 May 2008 03:07
by Ddoo
Ddoo wrote:
tltmusashi wrote:just do this:

Code: Select all

MySQLTable4.FieldByName('ProjectID').Value := edtQuoteNo.Text; 
MySQLTable4.FieldByName('Zone').Value := edtSelectZone.Text; 
MySQLTable4.FieldByName('EngMark').Value := edtEngMark.Text; 
MySQLTable4.Post();
Thanks for that. Yes that is how I am doing that also.

Problem. :?:
Why is it still writing to the first record always "B1" when the record selected and showing is actually B2. Even if I haven't previously called B1.

Note: I am using the "Edit-post" as shown previously. Is that OK? :?
A more definitive question....



//Select B2 record in a dbGrid

MySQLQuery4.Close;
MySQLQuery4.SQL.Clear;
MySQLQuery4.SQL.Add('SELECT * FROM projectboq where ProjectID = ' + '1' + ' AND ' + 'EngMark ='B2';
MySQLQuery4.ExecSQL;

//Edit the record for B2

// Last save to edtQuoteNo.Text = '1'
// Last save to edtEngMark.Text = 'B2'

MySQLTable4.Edit;
MySQLTable4.FieldByName('ProjectID').Value := '1';
......
......
MySQLTable4.FieldByName('EngMark').Value := 'B2';
MySQLTable4.Post;



// All OK!

NEXT... Get B3 record

//Select B3 from the table....


MySQLQuery4.Close;
MySQLQuery4.SQL.Clear;
MySQLQuery4.SQL.Add('SELECT * FROM projectboq where ProjectID = ' + '1' + ' AND ' + 'EngMark ='B3';
MySQLQuery4.ExecSQL;


//Edit the record for B3


// Save it to edtQuoteNo.Text = '1'
// Save it to edtEngMark.Text = 'B3'


MySQLTable4.Edit;
MySQLTable4.FieldByName('ProjectID').Value := '1';
.........
.........
MySQLTable4.FieldByName('EngMark').Value := 'B3';
MySQLTable4.Post;


// Failed.. The save is always the last successful save or 'Insert' record

// Is the MySQLTable4.Edit function the correct one.

Posted: Thu 08 May 2008 06:35
by Dimon
Please send a complete sample to dmitryg*crlab*com to demonstrate the problem, including a script to create and fill table.