Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我无法使我的SQL INSERT语句在Delphi7中处理关系中的两个表_Sql_Delphi_Ms Access_Delphi 7 - Fatal编程技术网

我无法使我的SQL INSERT语句在Delphi7中处理关系中的两个表

我无法使我的SQL INSERT语句在Delphi7中处理关系中的两个表,sql,delphi,ms-access,delphi-7,Sql,Delphi,Ms Access,Delphi 7,我一直得到以下错误 Project PAT_p.exe引发异常类EOleException,消息为“当前提供程序不支持从一次执行返回多个记录集”。进程已停止。使用步骤或运行继续 我数据库中的表以一对多的关系链接,其中ID是tbldelname中的PK,Nommer是autonumber,而PK是tblAntwoorde中的PK。不幸的是,这是学校的一项实际评估任务,两者之间的关系必须存在。 我的Delphi代码如下: Procedure TfrmDN.btnBDClick(Sender: TOb

我一直得到以下错误

Project PAT_p.exe引发异常类EOleException,消息为“当前提供程序不支持从一次执行返回多个记录集”。进程已停止。使用步骤或运行继续

我数据库中的表以一对多的关系链接,其中ID是tbldelname中的PK,Nommer是autonumber,而PK是tblAntwoorde中的PK。不幸的是,这是学校的一项实际评估任务,两者之间的关系必须存在。 我的Delphi代码如下:

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插入整数值


请帮忙

多亏了@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;

为什么在插入结束时将
qryVGKompetisieDB.Active
设置为True?如果在DB管理工具中执行这些SQL查询,会发生什么?什么是您的数据库引擎?@TLama我正在使采石场成为现实,因为它显示在dbgrid中。我不知道如何在我的DM管理工具中使用它。我使用的是Microsoft Access至少我可以看到一个问题,即您试图在
INSERT
查询中打开数据集。您已经将
SQL.Text
设置为
INSERT
查询并执行了它,但之后它不会将其更改回
SELECT
查询。您必须将
SQL.Text
设置为some
SELECT
query,然后将
Active
设置为True。@非常感谢您解决了这个问题。我只是在execute之后添加了一个select语句,它就工作了。我不认为您可以查看我关于sql中删除的另一个问题。这里是@DavidG,我不能接受它作为答案,因为它是作为评论发布的,而不是答案:/