with DataModule2.Queryinfo do begin close;SQL.Clear; SQL.Add('insert into info (ent_name,principal,address,phone,order,project,memo) '); SQL.Add('values('''+ent_name.Text+''','''+principal.Text+''','''+address.Text+''','''+phone.Text+''','''+order.Text+''','''+project.Text+''','''+memo.Text+''') '); ExecSQL; end;
DataModule2.Queryinfo.SQL.Add('(ent_name,principal,address,phone,order,project,memo)');
DataModule2.Queryinfo.SQL.Add('values ('
+QuotedStr(ent_name.Text)
+','+ QuotedStr(principal.Text)
+','+QuotedStr(address.Text)
+','+QuotedStr(phone.Text)
+','+QuotedStr(order.Text)'
+','+QuotedStr(project.Text)
+','+QuotedStr(memo.Text)
+')');
DataModule2.Queryinfo.SQL.Add('values('+'"'+ent_name.Text+'"'+','+'"'+principal.Text+'"'+','+'"'+address.Text+'"'+','+'"'+phone.Text+'"'+','+'"'+order.Text+'"'+','+'"'+project.Text+'"'+','+'"'+memo.Text+'"'+')');
DataModule2.Queryinfo.Active:=true;//这句话多余呀,Queryinfo的语句已经clear了;
DataModule2.Queryinfo.ExecSQL;
友问题
DataModule2.Queryinfo.SQL.Add('(ent_name,principal,address,phone,order,project,memo)');
DataModule2.Queryinfo.SQL.Add('values('+''''+ent_name.Text+''''+','+''''+principal.Text+''''+','+''''+address.Text+'"'+','+'"'+phone.Text+'"'+','+'"'+order.Text+'"'+','+'"'+project.Text+'"'+','+'"'+memo.Text+'"'+')');1、引号不要用'"',用''''
2、注意加入语句时 加入空格
如:
SQL.Add(‘ ent_name,principal,address,phone,order,project,memo) ');
begin
close;SQL.Clear;
SQL.Add('insert into info (ent_name,principal,address,phone,order,project,memo) ');
SQL.Add('values('''+ent_name.Text+''','''+principal.Text+''','''+address.Text+''','''+phone.Text+''','''+order.Text+''','''+project.Text+''','''+memo.Text+''') ');
ExecSQL;
end;
function AnsiQuotedStr(const S: string; Quote: Char): string;