数据库表CourseInfo中有字段14个,我想添加纪录进去,ado控件中应该用什么控件,怎么用?最好有一段实例。谢谢

解决方案 »

  1.   

    ado1.Close;
    ado1.SQL.Clear;
    ado1.SQL.Add('select * from 表名');
    ado1.Open;
    ado1.Append;
      

  2.   

    adoquery1.append;
    //赋值,或是在Grid中添加
    adoquery1.post;
      

  3.   

    ADOTable控件
    ADOTable.tablename='biaoming'
    ADOTable.open
    ADOTable.append 或者ADOTable.insert
      

  4.   

    ADOTable.append 后面该怎么写?
      

  5.   

    ADOTable.fieldByName("aa"):=Edit.text; //赋值
    ....................
    ADOTable.post;
      

  6.   

    ADOTable.fieldByName("aa"):=Edit.text; //赋值
    我怎么不能付值
      

  7.   

    看吧挺长的有帮助的
       with dmLookUps.adoconn  do
        begin
            BeginTrans;
            //-取得主表最大ID号
            lngMaxRdID := GetMaxRdID();
            //==========================================================================================
            // 更新最大单号表中主表ID
            //==========================================================================================
            strSQL := '';
            strSQL := 'UPDATE MaxVouch ';
            strSQL := strSQL + 'SET ';
            strSQL := strSQL + 'cInCode = ''' + inttostr(LngMaxRdID + 1) + '''';
            strSQL := strSQL + 'WHERE cVouch=''库存成品酒抽检记录主表ID''';
            Execute(strSQL);
            //-取得主表最大单据号
            strcCode := format(inttostr(LngMaxRdID),[0000000000]);
            //==========================================================================================
            // 添加记录至主表
            //==========================================================================================
            strSQL :='';
            strSQL := strSQL + 'INSERT INTO RdRecordInvChkNote (ID, bRdFlag,cVouchType,cBusType,cSource,cWhCode,dDate,cChecker,cPosCode) ';
            strSQL := strSQL + 'VALUES ';
            strSQL := strSQL + '(''' + inttostr(lngMaxRdID) + '''';
            strSQL := strSQL + ',1';
            strSQL := strSQL + ',30';
            strSQL := strSQL + ',''库存成品酒抽检记录''';
            strSQL := strSQL + ',''' + pSource + '''';
            strSQL := strSQL + ',''' + pWhCode + '''';
            strSQL := strSQL + ',''' + pDate + '''';
            strSQL := strSQL + ',''admin''';
            strSQL := strSQL + ',''' + pPosCode + '''';
            strSQL := strSQL + ')';
            Execute(strSQL);
            for iRow:=1 to editgrid.RowCount -1 do
            begin
               if editgrid.Cells[0,iRow]<>'' then           //有效记录
               begin
                //************************************************************************************
                // 添加记录至子表
                //************************************************************************************
                strSQL :='';
                strSQL := strSQL + 'INSERT INTO RdRecordsInvChkNote  (ID,cInvCode,iQuantity,dDate,cBatch,cWineBody,';
                strSQL := strSQL + 'cJuicePos,cHat,clabel,vCase,iSeep,cPosCode';
                strSQL := strSQL + ') ';
                strSQL := strSQL + 'VALUES ';
                strSQL := strSQL + '(''' + inttostr(lngMaxRdID) + '''';
                strSQL := strSQL + ',''' + editgrid.Cells[11,iRow] + '''';
                strSQL := strSQL + ',''' + editgrid.Cells[1,iRow] + '''';
                strSQL := strSQL + ',''' + editgrid.Cells[2,iRow] + '''';
                strSQL := strSQL + ',''' + editgrid.Cells[3,iRow] + '''';
                strSQL := strSQL + ',''' + editgrid.Cells[4,iRow] + '''';
                strSQL := strSQL + ',''' + editgrid.Cells[5,iRow] + '''';
                strSQL := strSQL + ',''' + editgrid.Cells[6,iRow] + '''';
                strSQL := strSQL + ',''' + editgrid.Cells[7,iRow] + '''';
                strSQL := strSQL + ',''' + editgrid.Cells[8,iRow] + '''';
                if editgrid.Cells[9,iRow] = '有' then
                begin
                   strSQL := strSQL + ',''' + InttoStr(1) + '''';
                end else begin
                   strSQL := strSQL + ',''' + InttoStr(0) + '''';
                end;
                strSQL := strSQL + ',''' + editgrid.Cells[10,iRow] + '''';
                strSQL := strSQL + ')';
                Execute(strSQL);
               end;
            end;
            try
              CommitTrans;
            except
              for i:= 0 to Errors.count-1 do begin
                result:=errors[i].Get_number;
              end;
              RollbackTrans;
            end;
        end;
      

  8.   

    用adoquery
    adoquery1.Close;
    adoquery1.SQL.Clear;
    adoquery1.SQL.Add('insert 表名 values(field1,field2,...field14)');
    adoquery1.Execsql;
      

  9.   

    也可以用Adocommand嘛,
    有点类似于楼上的,
    adocommand.commandtext:=('insert 表名 values(field1,field2,...field14)');
    adocommand.execute;
    喜喜,试试行不行!