SQL.Add('select * from Friend_Tab where U_Code = ''' + Combobox1.text +''' and '+ 'F_Name = '''+(QuotedStr(Edit1.text)+'''');
SQL.Add('select * from Friend_Tab where U_Code = ' + QuotedStr(Memo1.text) +#10+'and'+#10+ 'F_Name ='+ QuotedStr(Edit1.text));
在Delphi里写这些语句,总是那个'在作怪。我的经验是,被赋值的一这如果是数字,直接写上,如('where ID=1'), 如果是字符型的,要加两个'',即 ('where F_Name=''王五'''),如果引用如EDIT里面的值,则要加三个''',即: ('where F_Name='''+Edit1.Text+''''')。当然,查询时在不同的表内不一定成功。原因是使用的通配符不一样。在Access表中写成: ('where F_Name like '''+Edit1.Text+'*'+'''') 在interbase库和Ma Sql里则写成: ('where F_Name like '''+Edit1.Text+'%'+'''') Please try it yourself and test it.
Well, 100 Score always be answered quickly.
SQL.Add('select * from Friend_Tab where U_Code = ' + QuotedStr(Combobox1.text)) +'and' + 'F_Name = '+(QuotedStr(Edit1.text);
var sqlstr: string; sqlstr := 'select * from Friend_Tab where U_Code = ''' + (QuotedStr(Combobox1.text)) and F_Name = '+(QuotedStr(Edit1.text)); SQL.Add(sqlstr);
var sqlstr: string; sqlstr := 'select * from Friend_Tab where U_Code = :U_Code and F_Name=:F_Name'; sql.add(sqlstr); sql.parambyname('U_Code').asstring:=QuotedStr(Combobox1.text); sql.parambyname('F_Name').asstring:=QuotedStr(Edit1.text);
SQL.Add('select * from Friend_Tab where U_Code = ' +' QuotedStr(Combobox1.text) and ' +'F_Name = '''+(QuotedStr(Edit1.text)+''')';
Combobox1.text +''' and '+
'F_Name = '''+(QuotedStr(Edit1.text)+'''');
QuotedStr(Memo1.text) +#10+'and'+#10+
'F_Name ='+ QuotedStr(Edit1.text));
('where F_Name=''王五'''),如果引用如EDIT里面的值,则要加三个''',即:
('where F_Name='''+Edit1.Text+''''')。当然,查询时在不同的表内不一定成功。原因是使用的通配符不一样。在Access表中写成:
('where F_Name like '''+Edit1.Text+'*'+'''')
在interbase库和Ma Sql里则写成:
('where F_Name like '''+Edit1.Text+'%'+'''')
Please try it yourself and test it.
QuotedStr(Combobox1.text)) +'and' +
'F_Name = '+(QuotedStr(Edit1.text);
sqlstr: string;
sqlstr := 'select * from Friend_Tab where U_Code = ''' +
(QuotedStr(Combobox1.text)) and
F_Name = '+(QuotedStr(Edit1.text));
SQL.Add(sqlstr);
sqlstr: string;
sqlstr := 'select * from Friend_Tab where U_Code = :U_Code and F_Name=:F_Name';
sql.add(sqlstr);
sql.parambyname('U_Code').asstring:=QuotedStr(Combobox1.text);
sql.parambyname('F_Name').asstring:=QuotedStr(Edit1.text);
+' QuotedStr(Combobox1.text) and '
+'F_Name = '''+(QuotedStr(Edit1.text)+''')';
QuotedStr(Combobox1.text) +'''and ' +
'F_Name = '''+QuotedStr(Edit1.text)+'''');
Combobox1.text +''' and '+
'F_Name = '''+(QuotedStr(Edit1.text)+'''');
查询,插入记录都可以