Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1224483
  • 博文数量: 788
  • 博客积分: 4000
  • 博客等级: 上校
  • 技术积分: 7005
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-19 15:52
文章存档

2017年(81)

2011年(1)

2009年(369)

2008年(337)

分类:

2009-02-19 17:03:24



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

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;  
 

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

路过.同学....

分点分给我吧

要用哪个控件呢..?

天啊,我用ADOQuery1,

能告诉我第2个人说的用的是什么控件写的么?

或者谁能告诉我个新的方法么..!   感谢

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

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

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];

字段名,好像不能使用参数吧?



--------------------------
新闻:专注、极致、快、口碑 互联网创业的葵花宝典
导航:博客园首页  知识库  新闻  招聘  社区  小组  博问  网摘  找找看
阅读(931) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~