从表中读出一个字段,用combobox 做个下拉列表,不知道如取出来用?(即当前选中后的内容)
用combobox.items.text会把所有的值取出来,我只要当前选择的内容,并把这一行中另一个字段赋值给Lable,怎么处理?
表如下
id name class cec
1  张三  01    三年
2  李四  02    二年
3  王五  06    六年combobox 的下拉列表为  name中的内容 如选择李四,就让Lable= 02
 
还有如
select * from products where name='张三' 也总是报错,要怎么写啊?

解决方案 »

  1.   

    1.有两种方法:
    a.在combobox 中显示类似:
      张三(01)或01.张三   
      这样就可以从中取到01的值了
    b.取到张三后在数据表中用sql找
    2.这个问题已讨论过多次,name为SQL的关键字,所以要用:
    select * from products where [name]='张三' 
      

  2.   

    取到张三后在数据表中用sql找
    因为是新手,不知道怎么写,能否写细一下呢?
      

  3.   

    1.不等于怎么写?
      <>
    2.(用TADOQuery)
      ADOQuery1.SQL.Text:='select class from products where [name]='''+ComboBox1.Text+''''; //ComboBox1.Text为'张三'
     ADOQuery1.Open;
     if not ADOQuery1.eof then
        Label1.Caption:=ADOQuery1.FieldByName('class').AsString;
    ...