Hi - my brain is like birds - since hours I try to put some Data to Server but always error.
The Field in DB is a text field
I will Insert a widestring like with the code below...
but the windestring is always cut - and then error.
(when I execute the insert quers direct on server - all is ok)
procedure TForm1.Button1Click(Sender: TObject);
var xxx : WideString;
begin
xxx := 'ökjdfgh ökasj dfkjöhg ösdkjfhg öskdjfhg öksjdfhg öskdjfg dsöjkfgh ';
xxx := xxx + xxx + xxx + xxx+ xxx+ xxx+ xxx+ xxx+ xxx+ xxx+ xxx+ xxx+ xxx;
Myquery1.Sql.Text := 'INSERT INTO products_description '+
' (products_id, language_id, products_name, products_description) VALUES ' +
'(88889, 2, "ewewewewewewewe",'+xxx+'")';
myquery1.Execute;
end;
Am I dumb ? - WideString to SQL Insert
-
[email protected]
- Posts: 5
- Joined: Tue 05 Oct 2010 09:13
- Location: CH-Zürich
-
AndreyZ
Hello,
You forgot to quote the SQL code for the xxx string. The following SQL code is correct:
Also you can use parameters (it's a better way) in the following way:
You forgot to quote the SQL code for the xxx string. The following SQL code is correct:
Code: Select all
MyQuery.SQL.Text := 'INSERT INTO products_description (products_id, language_id, products_name, products_description) VALUES (88889, 2, "ewewewewewewewe","' + xxx + '")';Code: Select all
MyQuery.SQL.Text := 'INSERT INTO products_description (products_id, language_id, products_name, products_description) VALUES (:products_id, :language_id, :products_name, :products_description)';
MyQuery.ParamByName('products_description').AsString := xxx;-
[email protected]
- Posts: 5
- Joined: Tue 05 Oct 2010 09:13
- Location: CH-Zürich
Thanks...
ahhhhh now 100 lamps are going to burn....!!
Merci
MyQuery.SQL.Text := 'INSERT INTO products_description (products_id, language_id, products_name, products_description) VALUES (:products_id, :language_id, :products_name, :products_description)';
MyQuery.ParamByName('products_description').AsString := xxx;
MyQuery.ParamByName('products_id').AsString := myidvariable;
MyQuery.ParamByName('products_id').AsString := mylaguagevariable;
Sorry one more:
and when I will have a WHERE ?
eg WHERE products_id = myProductID
ahhhhh now 100 lamps are going to burn....!!
Merci
MyQuery.SQL.Text := 'INSERT INTO products_description (products_id, language_id, products_name, products_description) VALUES (:products_id, :language_id, :products_name, :products_description)';
MyQuery.ParamByName('products_description').AsString := xxx;
MyQuery.ParamByName('products_id').AsString := myidvariable;
MyQuery.ParamByName('products_id').AsString := mylaguagevariable;
Sorry one more:
and when I will have a WHERE ?
eg WHERE products_id = myProductID
-
AndreyZ
You can use WHERE clause in the following way:
Code: Select all
MyQuery.Sql.Clear;
MyQuery.Sql.Add('select * from products_description');
MyQuery.Sql.Add('where products_id = :myProductID');
MyQuery.ParamByName('myProductID').AsInteger := 1;
MyQuery.Open;