这是我写的一个数据录入的程序的一段总觉的不好,请各位大侠指点一下
begin
s_id:=AdoQuery1.FieldByName('s_id').value;
AdoQuery1.Close;
AdoQuery1.SQL.Clear;
AdoQuery1.SQL.Add('select * from s_sharp where s_id="'+s_id+'"');
AdoQuery1.Open;
{
*判断在形态信息表中是否已经存在相同信息。
}
if not AdoQuery1.Eof then
begin
ShowMessage('此人信息已经存在,请重新输入!');
AdoQuery1.Close;
end
else
begin
AdoQuery1.Close;
AdoQuery1.SQL.Clear;
AdoQuery1.SQL.add('insert into s_sharp(s_id,s_height,s_weight,s_upper_arm,s_lower_limbs,s_second_height,s_xingong,s_vital_capacity)');
AdoQuery1.SQL.add(' values(s_id,s_height,s_weight,s_upper_arm,s_lower_limbs,s_second_height,s_xingong,s_vital_capacity)');
AdoQuery1.Parameters.ParamByName('s_id').Value:=s_id;
AdoQuery1.Parameters.ParamByName('s_height').Value:=s_height.Text;
AdoQuery1.Parameters.ParamByName('s_weight').Value:=s_weight.Text;
AdoQuery1.Parameters.ParamByName('s_upper_arm').Value:=s_upper_arm.Text;
AdoQuery1.Parameters.ParamByName('s_lower_limbs').Value:=s_lower_limbs.Text;
AdoQuery1.Parameters.ParamByName('s_second_height').Value:=s_second_height.Text;
AdoQuery1.Parameters.ParamByName('s_xingong').Value:=s_xingong.Text;
AdoQuery1.Parameters.ParamByName('s_vital_capacity').Value:=s_vital_capacity.Text;
AdoQuery1.ExecSQL;
end;
end;