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.

解决方案 »

  1.   

    ADOQuery1控件没有关联到ADOCONNECTION组件(其中ADOCONNECTION要设置其ConnectionString属性)或直接设置ADOQuery1的ConnectionString属性。提示很清楚了。
      

  2.   

    Data Source=E:\MYJ\Data Entry\db1.mdb;Persist Security Info=True。
      

  3.   

    没见过这种写法,应该是ConnectionString才对。
      

  4.   

    j37796542
    你好,你在OPEN之前再加入一行代码ADOQuery1.Close;
    ADOQuery1.Open;
      

  5.   

    谢谢大家了,找到了,我用到的两个组件ADOQuery和ADOCONNECTION,都设置了ConnectionString属性,就可以了。   不是代码的问题,谢谢了