What is the best way to allow program to able to input single quote ?
Do i have to replace every single quote with double quote or is there other ( more automatic way ) ?
Single Quote in UNIDAC and SQL Server using Delphi
-
AndreyZ
Hello,
To input single quote from the code you can only use the following code:
Also you can easily input single quote using visual components.
To input single quote from the code you can only use the following code:
Code: Select all
UniQuery.Edit;
UniQuery.FieldByName('strfld').AsString := '''test''';
UniQuery.Post;Hello AndreyZ,
What do you mean by visual components ? if you mean it by using editbox, that's my problem. I want to input for example Sam's Restaurant.
so my editbox contain Sam's Restaurant.
so in my code it will look like this
if i run code above, an error occured
I have to replace every single quote in editbox1.text with 2 single quote.
Is there an easier way ?
What do you mean by visual components ? if you mean it by using editbox, that's my problem. I want to input for example Sam's Restaurant.
so my editbox contain Sam's Restaurant.
so in my code it will look like this
Code: Select all
Uniquery.edit;
Uniquery.fieldbyname('strfld').asstring := '''+editbox1.text+''';
uniquery.post;
I have to replace every single quote in editbox1.text with 2 single quote.
Is there an easier way ?
-
AndreyZ
You can use the following code:
Code: Select all
UniQuery.Edit;
UniQuery.FieldByName('strfld').AsString := Edit1.Text; // Edit1.Text = Sam's Restaurant
UniQuery.Post;Use QuotedStr Delphi function:overvi wrote:if i run code above, an error occuredCode: Select all
Uniquery.edit; Uniquery.fieldbyname('strfld').asstring := '''+editbox1.text+'''; uniquery.post;
I have to replace every single quote in editbox1.text with 2 single quote.
Is there an easier way ?
Code: Select all
Uniquery.edit;
Uniquery.fieldbyname('strfld').asstring := QuotedStr(editbox1.text);
uniquery.post;