数据库载入数据 新手问题。
procedure TForm4.Button1Click(Sender: TObject);
begin
if (trim(edit2.Text)<>'')and(trim(edit3.Text)<>'')and(trim(edit3.Text)=trim(edit2.Text)) then
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add('insert into student(Sno,Sname,Sex,Sage,Sdept) values('+quotedstr(edit1.Text)+','+quotedstr(edit2.Text)+','+quotedstr(edit3.Text)+',DateTimePicker1.date,'+quotedstr(edit4.Text)+',');
adoquery1.open ;
end;
过程简述:
单击按钮Button1,对表student插入数据元组。Sno,Sname,Sex,Sage,Sdept
运行时,DateTimePicker1.date这里出现错误,说上下文中不能使用date,此处只能使用常量变量或表达式,不允许使用列名。