delphi的一个程序问题!

来源:百度知道 编辑:UC知道 时间:2024/05/15 13:30:46
unit Unit3;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;

type
TCR1 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Button1: TButton;
Button2: TButton;
Memo1: TMemo;

procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
CR1: TCR1;

implementation

uses Unit1, Unit2;

{$R *.dfm}

Sql2:='Insert xs values('''+Xh+''','''+Xm+''','+Xb+','''+Cssj+''',
'''+Zy+''','+Zxf+','''+Bz+''')'; //这里有问题!!!!
改成:

Sql2:='Insert xs values('+
''''+Xh+''''+','+
''''+Xm+''''+','+
'''+Xb+''''+','+
DateToStr(Cssj)+','+
''''+Zy+''''+','+
FloatTostr(Zxf)+','+
''''+Bz+''''+')';
以上我假设xh是序号,字符型的,xm是姓名,字符型的,xb是性别字符型的,Cssj时间型的,zy摘要字符型的,Bz备注字符型的。sql2中的引号均为单引号。