On sql server, when executing Insert with parameters, Prepare caused an error,
e.g
uniQuery1.SQL.Text:='Insert into t1 (f3) values (:f3)';
uniQuery1.Prepare;//here error
uniSQL.SQL.Text:='Insert into t1 (f1) values (:f1)';
uniSQL.Prepare;
uniSQL.Execute;//here error.
Can't Prepare sql: Insert into t1 (f3) values (:f3)
Re: Can't Prepare sql: Insert into t1 (f3) values (:f3)
Hi,
You must assign a value to the parameter before prepare.
Something like this:
uniQuery1.ParamByName('f3').ParamType := ptInput;
uniQuery1.ParamByName('f3').DataType := ftString;
uniQuery1.ParamByName('f3').AsString := 'P';
You must assign a value to the parameter before prepare.
Something like this:
uniQuery1.ParamByName('f3').ParamType := ptInput;
uniQuery1.ParamByName('f3').DataType := ftString;
uniQuery1.ParamByName('f3').AsString := 'P';
Re: Can't Prepare sql: Insert into t1 (f3) values (:f3)
UniQuery can automatically request parameter properties (Name, ParamType, DataType, Size, TableTypeName) from the server when the TUniQuery.Prepare method is executed. For this, you should specify True to the special DescribeParams property:
UniQuery1.SpecificOptions.Add('DescribeParams=True');
Alternatively, you can specify the parameters properties manually before executing the Prepare method, as we already advised in the previous post.
More details about the DescribeParams property: https://www.devart.com/sdac/docs/index. ... params.htm
UniQuery1.SpecificOptions.Add('DescribeParams=True');
Alternatively, you can specify the parameters properties manually before executing the Prepare method, as we already advised in the previous post.
More details about the DescribeParams property: https://www.devart.com/sdac/docs/index. ... params.htm