There is a field ~ "CodeTypNM" VARCHAR(30) ~ in a table ~ SysCode
i want to insert a value '機型名稱與序號b對應表' into the field "CodeTypNM"
if i format a "insert" sql command ~ it's work
but if i want to use the follwing code to insert the
with sysCode do
begin
...
CodeTypNM := '機型名稱與序號b對應表';
....
end;
dm.aureliusManager.Save(sysCode);
the value in "CodeTypNM" will be '機型名稱與'
Can anyone tell why ? TKS
Which database component are you using to save the data? Have you tried to perform a raw insert SQL statement using that component? Which code did you use?
My question is: what component have you configured to save data? FireDAC? UniDAC? The native MSSQL driver (if you are using Microsoft SQL Server)?
And how did you tried to perform a raw insert SQL? In a database admin tool? From Delphi? If from Delphi, which code did you use to execute the raw SQL?
And how did you tried to perform a raw insert SQL? In a database admin tool? From Delphi? If from Delphi, which code did you use to execute the raw SQL?
i perform a raw insert SQL using Delphi
using the following code
Connection := ADOConnection;
SQL.Clear;
SQL.Add(GenSysCodeKindSQL(MachNameMapTob,'機型名稱與序號b對應表'))
ExecSQL;
function GenSysCodeKindSQL(CodeType,CodeTypNM:string): string;
begin
Result := Concat('INSERT INTO SysCode (CodeType,CodeTypNM,CodeInx,CodeNo,CodeNM,CodeDesc,NotShow,CreateDate,CreateUser,UpdateDate,UpdateUser)',
' VALUES(''' + CodeType + ''',''' + CodeTypNM + ''',0,''*'','''','''',''False'',GetDate(),''cova'',Null,'''') ');
end;
I kindly ask you that you refactor your test to use parameters, instead of setting the field content directly into the SQL statement.
My guess is that ADOQuery is cropping the parameter. Try to set the parameter type as ftString or ftWideString, set the value using the Value property and see the behavior, please.
Well, that's pretty much what Aurelius does when using ADO, in unit Aurelius.Drivers.dbGo.
You can try to check it yourself, putting a breakpoint in line 148:
Parameter.DataType := P.ParamType;
if P.ParamType = ftDateTime then
Parameter.ParameterObject.Type_ := adDBTimeStamp;
Parameter.Value := P.ParamValue;
Parameter.Direction := pdInput;
if (Parameter.DataType in [ftString, ftFixedChar, ftWideString, ftFixedWideChar]) and (Parameter.Size <= 0) then
Parameter.Size := 1;
And check the values there (P.ParamType and P.ParamValue). Other than this, we should check and debug to better see what's going on. If after debugging you can't find out what's going on (if maybe it's some configuration in ADO, or database), please send us a minimal project and steps to reproduce the issue, so we can check it at our side. Thank you.
We didn't receive it. I suggest you send us a private message via this forum, it's more guaranteed that we received (and you can track it) instead of an e-mail.
To send a private message, just click my name and click the button "Message":