各位大哥 小弟刚学delphi不仅, 我想把comboBox里选择的内容写到数据库里面但是不是直接写进去而是用数字表示,举一个例子说把比如我在comBox里选择南京 写到数据库里不是直接写南京 而是用01表示 请问这样怎么写 ?  
                                     我用ADO连的数据库
                                     希望会的大哥能帮帮忙
                                     小弟非常感谢?

解决方案 »

  1.   

    if combobox.text='南京' then
    begin
      try
        query.sql.text:='insert into 表 values(''01'')';
        query.exsql;
      finally
        query.close;
    end;
      

  2.   

    if combobox1.text='河南' then
    begin
     ShowMessage('ok');
      try
        adoquery1.sql.text:='insert into systab (countdays) values(''01'')';
       adoquery1.Execsql;
      finally
        adoquery1.close;
         showmessage('ok1');
    end;
    我就是照上面这个方法写的 也能编译通过 可就是存进去的不是想要写的01 而是以前的数据
    复制了一遍, 这是什么原因呀
      

  3.   


    ComboBox1.Clear;
      for i:=0 to ADOQuery1.FieldCount-1 do
        ComboBox1.Items.Add(ADOQuery1.Fields[i].FieldName);
      

  4.   

    if ComboBox1.Text:= '南京' then
       temp := '01';
    AdoCommand1.Text := 'insert into yourTable(Field1) value (:p1)' ;
    AdoCommand1.Parameters.ParamByName('CustId').Value := temp ;
    AdoCommand1.Execute;
      

  5.   

    [Error] Unit1.pas(115): Undeclared identifier: 'Text'
    怎么办呢
      

  6.   

    我说的是AdoCommand1.Text := 'insert into yourTable(Field1) value (:p1)' ;
    (;p1)什么意思呢
    编译时
    [Error] Unit1.pas(115): Undeclared identifier: 'Text'
    怎么办