SDAC TMSQuery Post-Problem

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
scheuermann69
Posts: 2
Joined: Sat 13 Oct 2007 17:05

SDAC TMSQuery Post-Problem

Post by scheuermann69 » Sat 13 Oct 2007 17:20

Hallo,

i have a great problem with inserting data in a table with TMSQuery.

My Code:

MSQueryTable.SQL.Clear;
MSQueryTable.SQL.Add('select * from Benutzer');
MSQueryTable.Open;
MSQueryTable.Insert;
MSQueryTable.FieldByName('Benutzer').Value := AdvEdit2.Text;
MSQueryTable.FieldByName('WindowsBenutzer').Value := GetWindowsUserName;
MSQueryTable.FieldByName('Vorname').Value := AdvEdit3.Text;
MSQueryTable.FieldByName('Name').Value := AdvEdit4.Text;
MSQueryTable.FieldByName('TelefonBez1').Value := 'Telefon1';
MSQueryTable.FieldByName('TelefonBez2').Value := 'Telefon2';
MSQueryTable.FieldByName('TelefonBez3').Value := 'Telefon3';
MSQueryTable.FieldByName('Land').Value := 'D';
MSQueryTable.FieldByName('Status').Value := 1;
MSQueryTable.FieldByName('Angelegt am').Value := Now;
MSQueryTable.FieldByName('Angelegt von').Value := ls_benutzer;
MSQueryTable.FieldByName('Bearbeitet am').Value := Now;
MSQueryTable.FieldByName('Bearbeitet von').Value := ls_benutzer;
MSQueryTable.Post;

The Program crashes at the Field 'Angelegt am'.

In SDAC 4.30.0.12 the Statement in your Debug-Window is:

INSERT INTO Benutzer
(Benutzer, Windowsbenutzer, Name, Vorname, Land, TelefonBez1, TelefonBez2, TelefonBez3, Status, Angelegt am, Angelegt von, Bearbeitet am, Bearbeitet von)
VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)


:Benutzer(FixedChar[2],IN)='es'
:Windowsbenutzer(FixedChar[7],IN)='PC1'
:Name(FixedChar[10],IN)='Mustermann'
:Vorname(FixedChar[5],IN)='Erwin'
:Land(FixedChar[1],IN)='D'
:TelefonBez1(FixedChar[8],IN)='Telefon1'
:TelefonBez2(FixedChar[8],IN)='Telefon2'
:TelefonBez3(FixedChar[8],IN)='Telefon3'
:Status(Integer,IN)=1
:[Angelegt am](DateTime,IN)=13.10.2007 19:07:14
:[Angelegt von](FixedChar[2],IN)='es'
:[Bearbeitet am](DateTime,IN)=13.10.2007 19:07:14
:[Bearbeitet von](FixedChar[2],IN)='es'

In SDAC 3.80.0.34 the Statement (in your Debug-Window) is:

INSERT INTO Benutzer
(Benutzer, Windowsbenutzer, Name, Vorname, Land, TelefonBez1, TelefonBez2, TelefonBez3, Status, [Angelegt am], [Angelegt von], [Bearbeitet am], [Bearbeitet von])
VALUES
(:1,:2,:5,:6,:9,:12,:14,:16,:34,:35,:36,:37,:38)


:1(FixedChar[2],IN)='es'
:2(FixedChar[7],IN)='PC1'
:5(FixedChar[10],IN)='Mustermann'
:6(FixedChar[5],IN)='Erwin'
:9(FixedChar[1],IN)='D'
:12(FixedChar[8],IN)='Telefon1'
:14(FixedChar[8],IN)='Telefon2'
:16(FixedChar[8],IN)='Telefon3'
:34(Integer,IN)=1
:35(DateTime,IN)=13.10.2007 19:07:14
:36[Angelegt von](FixedChar[2],IN)='es'
:37[Bearbeitet am](DateTime,IN)=13.10.2007 19:07:14
:38[Bearbeitet von](FixedChar[2],IN)='es'

This Statement works fine.
Can you help me to let work this in SDAC 4.x ?

PS: QuotedIdentifier is set to true in the Connection-Component.

Thank you for every Statement
E. Scheuermann

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 15 Oct 2007 09:39

Try to set the QuoteNames option of TMSQuery to True.

scheuermann69
Posts: 2
Joined: Sat 13 Oct 2007 17:05

Thank you Antaeus

Post by scheuermann69 » Mon 15 Oct 2007 10:26

Hallo Antaeus,

thank you very much for the fast reply.
That was it - i don't looked at this option.

Thanks and a good day
E. Scheuermann

Post Reply