用ado控件如何添加一条纪录 数据库表CourseInfo中有字段14个,我想添加纪录进去,ado控件中应该用什么控件,怎么用?最好有一段实例。谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ado1.Close;ado1.SQL.Clear;ado1.SQL.Add('select * from 表名');ado1.Open;ado1.Append; adoquery1.append;//赋值,或是在Grid中添加adoquery1.post; ADOTable控件ADOTable.tablename='biaoming'ADOTable.openADOTable.append 或者ADOTable.insert ADOTable.append 后面该怎么写? ADOTable.fieldByName("aa"):=Edit.text; //赋值....................ADOTable.post; ADOTable.fieldByName("aa"):=Edit.text; //赋值我怎么不能付值 看吧挺长的有帮助的 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; 用adoqueryadoquery1.Close;adoquery1.SQL.Clear;adoquery1.SQL.Add('insert 表名 values(field1,field2,...field14)');adoquery1.Execsql; 也可以用Adocommand嘛,有点类似于楼上的,adocommand.commandtext:=('insert 表名 values(field1,field2,...field14)');adocommand.execute;喜喜,试试行不行! 一个 Delphi 的群:13830859 各位高手让软件自动适应 800 X 600 和 1024 X 768 应该怎么做?谢谢大家 不明不白的丢失引号`~~~急啊`~~~顶者有份`~~~` 问个难一点的问题,高手请进! 怎样作一个类似sqlmanager的程序?? 菜鸟继续提问,帮忙啦 Borland编程大赛的试题! 纯送分帖:烟鬼程序员请看进来!斑竹手下留情不要删帖呀!~~~~ 如何将Query控件来查询出来的记录输出报表? 问一初级问题? 关于批提交? 那里有dbgrideh的例子
ado1.SQL.Clear;
ado1.SQL.Add('select * from 表名');
ado1.Open;
ado1.Append;
//赋值,或是在Grid中添加
adoquery1.post;
ADOTable.tablename='biaoming'
ADOTable.open
ADOTable.append 或者ADOTable.insert
....................
ADOTable.post;
我怎么不能付值
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;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('insert 表名 values(field1,field2,...field14)');
adoquery1.Execsql;
有点类似于楼上的,
adocommand.commandtext:=('insert 表名 values(field1,field2,...field14)');
adocommand.execute;
喜喜,试试行不行!