1

我不断收到以下错误

项目 PAT_p.exe 引发异常类 EOleException,并带有消息“当前提供程序不支持从单个执行返回多个记录集”。进程停止。使用 Step 或 Run 继续。

我的数据库中的表以一对多的关系链接,其中 ID 是 tblDeelname 中的 PK,Nommer 是自动编号,而 tblAntwoorde 中的 PK。不幸的是,这是针对学校的实际评估任务,并且必须存在这种关系。我的德尔福代码如下:

Procedure TfrmDN.btnBDClick(Sender: TObject);
var

sNaam, sVan, sKNommer, sAntwoord, sInteger : string;

begin

 sNaam := lblNaam2.Caption;              //
 sVan := lblVan2.Caption;                //Declaring Strings
 sKNommer := lblKN2.Caption;             //
 sAntwoord := lblAntwoord1.Caption;      //
 inc(iTInskrywings);          // Global var starting at 100 which is declared on form activate
 sInteger := intostr(iTInskrywings);

 frmData.qryVGKompetisieDB.Active := false;    // query is on another form
 frmData.qryVGKompetisieDB.SQL.Text := 'insert into tblDeelnemers (ID, Naam, Van, Kontaknommer) VALUES ("'+sInteger+'", "'+sNaam+'", "'+sVan+'","'+sKNommer+'")'; // Inserting Data into first Table
 frmData.qryVGKompetisieDB.ExecSQL;
 frmData.qryVGKompetisieDB.SQL.Text := 'insert into tblAntwoorde (ID, Antwoord) VALUES ("'+sInteger+'", "'+sAntwoord+'")';   // Inserting Data into second Table
 frmData.qryVGKompetisieDB.ExecSQL;
 frmData.qryVGKompetisieDB.Active := true;

end;

进入表格的所有信息都来自编辑框,ID 是一个全局变量(也是必须存在的评估的一部分)。由于在这个女巫不希望我用 sql 插入整数值之前出现的另一个错误,我将整数变成了字符串。

请帮忙!!!

4

1 回答 1

2

感谢@TLama,我通过仅在最后一次执行后添加 select 语句来纠正我的愚蠢错误。

Procedure TfrmDN.btnBDClick(Sender: TObject);
var

sNaam, sVan, sKNommer, sAntwoord, sInteger : string;

begin

 sNaam := lblNaam2.Caption;              
 sVan := lblVan2.Caption;                
 sKNommer := lblKN2.Caption;             
 sAntwoord := lblAntwoord1.Caption;      
 inc(iTInskrywings);          
 sInteger := intostr(iTInskrywings);

 frmData.qryVGKompetisieDB.Active := false;    
 frmData.qryVGKompetisieDB.SQL.Text := 'insert into tblDeelnemers (ID, Naam, Van, Kontaknommer) VALUES ("'+sInteger+'", "'+sNaam+'", "'+sVan+'","'+sKNommer+'")'; 
 frmData.qryVGKompetisieDB.ExecSQL;
 frmData.qryVGKompetisieDB.SQL.Text := 'insert into tblAntwoorde (ID, Antwoord) VALUES ("'+sInteger+'", "'+sAntwoord+'")';   
 frmData.qryVGKompetisieDB.ExecSQL;
 frmData.qryVGKompetisieDB.SQL.Text := 'SELECT * FROM tblDeelnemers'; // The select statement needs to be there so that the dbgrid can display properly  
 frmData.qryVGKompetisieDB.Active := true;

end;
于 2013-09-09T01:20:57.057 回答