请问操作ACCESS数据库时
如果数据库是
表 word
字段 name 字段 pass读access把所有的name 加入combobox控件中 然后 点里面的内容就在edit1.text中显示对应的pass内容

解决方案 »

  1.   

    1。
    with QDate do
      begin
        open;
        First;
        Repeat
          combobox.Items.Add(FieldByName('name').AsString);
          Next;
        until EOF;
        Close;
      end;
    end;2。在combobox的OnChange
    with QDate do
      begin
        close;
          QDate.sql.clear;
          QDate.sql='slect * from word where [name] ='+combobox.Text;
        open;
          edit1.text:=FieldByName('pass').AsString;
        Close;
      end;
    end;
      

  2.   

    呵呵,错了句
    QDate.sql.add('slect * from word where [name] ='+combobox.Text);
      

  3.   

    搞定了 可是方法不行啊
    1。
    with QDate do
      begin
        open;
        First;
        Repeat
          combobox.Items.Add(FieldByName('name').AsString);
          Next;
        until EOF;
        Close;
      end;
    end;这里就没指定是word表的啊?...
      

  4.   

    我晕 对 ADOQuery  初始化的时候在 SQL语句中不是写的很清楚了 from word 吗 ? 
    然后才对ADOQuery进行操作啊。 如果 用 ADOTable则就在 Name中指定不就好了
      

  5.   

    3个问题。
    1、name最好不要作为字段名,这是数据库的保留字,如果要使用请这样写[name]
    2、遍历数据集记录,使用while比较正规,这样写:
    with AdoDataSet do
    begin
       if active then active:=false;
       commandtext:='select * from word';
       active:=true;
       combobox1.clear; combobox2.clear;
       while (not eof) do
       begin
          combobox1.items.add(FieldByName('Name').asstring);
          combobox2.items.add(FieldByName('pass').asstring);
          Next;
       end;
       Close;
    end;
    3、实现你的功能,请在combobox1的onchange时间里写:
       Edit1.text:=combobox2.items[combobox1.itemindex];