Using Delphi 2009 and MySql Data Access components v. 5.80.0.48. I am unable to update when tablefieldname contains a period.
To reproduce:
CREATE TABLE `test` (
`ID` int(11) NOT NULL auto_increment,
`Field1` varchar(20) default NULL,
`Field.1` varchar(20) default NULL,
`Field1.` varchar(20) default NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
If posting to
1) Table.FieldbyName('Field1').AsString := 'Test'; -- this is ok
2) Table.FieldbyName('Field.1').AsString := 'Test'; -- this fails with error "Unknown column 'Field.1' in 'field list'
3) Table.FieldbyName('Field1.').AsString := 'Test'; -- this fails with error "#42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')
VALUES
('Test1')' at line 2.
---------------------------
OK
---------------------------"
Before upgrading to Delphi 2009 I used Delphi 2006, and here all worked ok.
Do you have a solution for this big problem?
Unable to post when fieldname contains a period.
component error?
Setting debug on shows this
FIELDNAME = Field.1
UPDATE `test`
SET
`Field`.`1` = ?
WHERE
`ID` = ?
:`Field`.`1`(String[2],IN)='xx'
:`Old_ID`(Integer,IN)=1
I think it should do this:
UPDATE `test`
SET
`Field.1` = ? ------ here changed
WHERE
`ID` = ?
:`Field`.`1`(String[2],IN)='xx'
:`Old_ID`(Integer,IN)=1
where Fieldname = Field1 debug shows
UPDATE `test`
SET
`Field1`. = ?
WHERE
`ID` = ?
:`Field1`.(String[4],IN)='test'
:`Old_ID`(Integer,IN)=1
and this should be
UPDATE `test`
SET
`Field1. = ? ------- here changed
WHERE
`ID` = ?
:`Field1`.(String[4],IN)='test'
:`Old_ID`(Integer,IN)=1
FIELDNAME = Field.1
UPDATE `test`
SET
`Field`.`1` = ?
WHERE
`ID` = ?
:`Field`.`1`(String[2],IN)='xx'
:`Old_ID`(Integer,IN)=1
I think it should do this:
UPDATE `test`
SET
`Field.1` = ? ------ here changed
WHERE
`ID` = ?
:`Field`.`1`(String[2],IN)='xx'
:`Old_ID`(Integer,IN)=1
where Fieldname = Field1 debug shows
UPDATE `test`
SET
`Field1`. = ?
WHERE
`ID` = ?
:`Field1`.(String[4],IN)='test'
:`Old_ID`(Integer,IN)=1
and this should be
UPDATE `test`
SET
`Field1. = ? ------- here changed
WHERE
`ID` = ?
:`Field1`.(String[4],IN)='test'
:`Old_ID`(Integer,IN)=1