如何用query空间来知道表的字段名称,谢谢

解决方案 »

  1.   

    for i := 0 to query.fieldcount-1 do
      showmessage(query.fields[i].fieldname);
      

  2.   

    adoquery1.Close;
     adoquery1.SQL.clear;
     adoquery1.SQL.add('insert into w1 values(1,1,1,1,1)');
     adoquery1.ExecSQL;这是一段连接往sql数据库中插入记录的语句,旧这几条语句,竟然老出错,
    Access violation at address 1F487CAB in module 'msado15.dll'. Write of address 01009024.请高手指点
      

  3.   

    楼上的兄弟,我的字段只有一个是数字型的,其他的都是字符类的,我在sql serve里试了是好的。请指点
      

  4.   

    我这个程序当你执行的时候,他会提示Access violation at address 1F487CAB in module 'msado15.dll'. Write of address 01009024.但是重新调用的时候他已经将记录查进表中了,请高手指点,这是怎么回事
      

  5.   

    Access violation at address 1F487CAB in module 'msado15.dll'. Write of address 01009024.
    ADOQuery不能重复使用。
    建议动态创建ADOQuery就没有如上错误。
    如:
    var
    adoquery1:=TAdoQuery
    begin
      adoquery1.create(nil);
      ADOQuery1.ConnectionString:='';  
    adoquery1.SQL.add('insert into w1 values(1,1,1,1,1)');
    end;
      

  6.   

    谢谢楼上的兄弟,还想请教个问题 if (str='integer') or (str='float') or (str='date') or (str='time') or (str='timestamp') then
        begin
           table1.TableName:=trim(edit1.Text);
           table1.Active :=true;
          for i:=0 to table1.Fields.Count -1 do
             begin
                if trim(edit3.Text)=table1.Fields[i].FieldName   then
                         begin
                           application.MessageBox('ÇëÊäÈë×Ö¶ÎÃûÒѾ­´æÔÚ£¬ÇëÊäÈëÆäËûµÄÃû³Æ','Ìáʾ',0);
                           edit3.SetFocus;
                           exit;
                         end;
             end;
        query1.SQL.Add('alter table '+trim(edit1.Text)+' add '+trim(edit3.Text)+' '+trim(combobox1.Text));
      end;我现在碰到的情况是这样的,我现在增加了一个字段,如果我继续想增加的话,我想来判断表中是否有已经存在的字段名,但是这里我用table来判断的话,他不能判断刚才加入的字段名,不知道这个问题有那位朋友给我指点一下,谢了