用以下代码向数据表插入数据
begin
with SQLQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('Insert into STUDENT values (:sn,:sname,:birth)');
ParamByName('sn').Value:=edit1.Text;
ParamByName('sname').Value:=edit2.Text;
ParamByName('birth').Value:=DateTimePicker1.Date;
ExecSQL;
end;
end;
end.出现错误提示信息:
conversion error from string "39630.72446909722"
begin
with SQLQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('Insert into STUDENT values (:sn,:sname,:birth)');
ParamByName('sn').Value:=edit1.Text;
ParamByName('sname').Value:=edit2.Text;
ParamByName('birth').Value:=DateTimePicker1.Date;
ExecSQL;
end;
end;
end.出现错误提示信息:
conversion error from string "39630.72446909722"
上面这一句有问题,你把它转换成字符串试试
ParamByName('birth').Value:=datetostr(DateTimePicker1.Date);
DEPHI中最容易犯错的就是类型不一致.
conversion error from string "39630.72446909722"
按照楼上的转换数据类型吧