关于delphi数据添加的问题
var
i:integer;
begin
ADOQuery1.SQL.Text := 'select * from ODate'; //ODate为数据库表的名称
ADOQuery1.Open;
for i := 1 to StringGrid1.RowCount - 1 do
begin
ADOQuery1.Edit;
ADOQuery1.FieldByName('Num').AsString := StringGrid1.Cells[1, I]; //Num为表中字段
ADOQuery1.Post;
end;
end;
为什么启动程序点击存入数据的时候报错,执行到ADOQuery1.Open时候出错。请指教下。
错误提示:
Project Project1.exe raidsed exception class EDatabaseError with message 'Missing Connection or ConnectionString'
Process Stoped. Use Step or Run to continue.
[解决办法]
ADOQuery1控件没有关联到ADOCONNECTION组件(其中ADOCONNECTION要设置其ConnectionString属性)或直接设置ADOQuery1的ConnectionString属性。
提示很清楚了。
[解决办法]
j37796542
你好,你在OPEN之前再加入一行代码
ADOQuery1.Close;
ADOQuery1.Open;