太
太阳雨晨
Unregistered / Unconfirmed
GUEST, unregistred user!
我用adoquery对表lsntbl进行插入记录,其中要用到表lsntsk的数据,表lsntsk中有一字段
为char型,我在delphi中与之对应的是string,程序如下:
procedure tscjbkb.scjbkbp;
var
k,j,time,classroomid,teacherid,lsnnmb:integer;
classid1,classid2,classid3,classid4,mltnmb: integer;
i:extended;
typt:string;
begin
datamodule2.ADODataSetlsntbl.Open;
if datamodule2.ADODataSetlsntbl.RecordCount<>0 then
begin
showmessage('基本课程表已经生成!');
datamodule2.ADODataSetlsntbl.Close
end
else
begin
datamodule2.ADODataSetlsntbl.Close;
datamodule2.ADODataSetlsntsk.Open;
datamodule2.ADODataSetlsntsk.Sort:='rank';
datamodule2.ADODataSetlsntsk.First;
while not datamodule2.ADODataSetlsntsk.Eof do
begin
i:=datamodule2.ADODataSetlsntsk.fieldbyname('weektime').value;
k:=getint(i);
teacherid:=datamodule2.ADODataSetlsntsk.fieldbyname('teacherid').value;
classid1:=datamodule2.ADODataSetlsntsk.fieldbyname('classid1').value;
classid2:=datamodule2.ADODataSetlsntsk.fieldbyname('classid2').value;
classid3:=datamodule2.ADODataSetlsntsk.fieldbyname('classid3').value;
classid4:=datamodule2.ADODataSetlsntsk.fieldbyname('classid4').value;
mltnmb:=datamodule2.ADODataSetlsntsk.fieldbyname('mltnmb').value;
typt:=datamodule2.ADODataSetlsntsk.fieldbyname('typt').value;
lsnnmb:=datamodule2.ADODataSetlsntsk.fieldbyname('lsnnmb').Value;
datamodule2.adoqueryinsert.Parameters.ParamByName('sngdbl').value:=NuLL;
datamodule2.adoqueryinsert.Parameters.ParamByName('lsntskid').value
:=datamodule2.ADODataSetlsntsk.fieldbyname('lsntskid').Value;
for j:=1 to k do
begin
time:=gettime(j*2-1,lsnnmb);
while (not pdtimeclass(time,classid1,classid2,classid3,classid4)) or (not pdtimeteacher(time,teacherid)) do
time:=getnexttime(time,lsnnmb);
classroomid:=getclassroom(mltnmb,typt);
while not (pdtimeclassroom(time,classroomid)) do
classroomid:=getnextclassroom(classroomid,typt);
while not (pdtimeclassroom(time,classroomid)) do
begin
time:=getnexttime(time,lsnnmb);
while (not pdtimeclass(time,classid1,classid2,classid3,classid4)) or (not pdtimeteacher(time,teacherid)) do
time:=getnexttime(time,lsnnmb);
classroomid:=getclassroom(mltnmb,typt);
while not (pdtimeclassroom(time,classroomid)) do
classroomid:=getnextclassroom(classroomid,typt);
end;
datamodule2.adoqueryinsert.Parameters.ParamByName('time').Value:=time;
datamodule2.adoqueryinsert.Parameters.ParamByName('classroomid').Value:=classroomid;
datamodule2.adoqueryinsert.ExecSQL;
end;
datamodule2.adodatasetlsntsk.Next;
end;
datamodule2.ADODataSetlsntsk.close;
end;
end;
程序在 typt:=datamodule2.ADODataSetlsntsk.fieldbyname('typt').value;处出错,提示为
:invalid variant type conversion.
请问这是何故?该怎么办?
为char型,我在delphi中与之对应的是string,程序如下:
procedure tscjbkb.scjbkbp;
var
k,j,time,classroomid,teacherid,lsnnmb:integer;
classid1,classid2,classid3,classid4,mltnmb: integer;
i:extended;
typt:string;
begin
datamodule2.ADODataSetlsntbl.Open;
if datamodule2.ADODataSetlsntbl.RecordCount<>0 then
begin
showmessage('基本课程表已经生成!');
datamodule2.ADODataSetlsntbl.Close
end
else
begin
datamodule2.ADODataSetlsntbl.Close;
datamodule2.ADODataSetlsntsk.Open;
datamodule2.ADODataSetlsntsk.Sort:='rank';
datamodule2.ADODataSetlsntsk.First;
while not datamodule2.ADODataSetlsntsk.Eof do
begin
i:=datamodule2.ADODataSetlsntsk.fieldbyname('weektime').value;
k:=getint(i);
teacherid:=datamodule2.ADODataSetlsntsk.fieldbyname('teacherid').value;
classid1:=datamodule2.ADODataSetlsntsk.fieldbyname('classid1').value;
classid2:=datamodule2.ADODataSetlsntsk.fieldbyname('classid2').value;
classid3:=datamodule2.ADODataSetlsntsk.fieldbyname('classid3').value;
classid4:=datamodule2.ADODataSetlsntsk.fieldbyname('classid4').value;
mltnmb:=datamodule2.ADODataSetlsntsk.fieldbyname('mltnmb').value;
typt:=datamodule2.ADODataSetlsntsk.fieldbyname('typt').value;
lsnnmb:=datamodule2.ADODataSetlsntsk.fieldbyname('lsnnmb').Value;
datamodule2.adoqueryinsert.Parameters.ParamByName('sngdbl').value:=NuLL;
datamodule2.adoqueryinsert.Parameters.ParamByName('lsntskid').value
:=datamodule2.ADODataSetlsntsk.fieldbyname('lsntskid').Value;
for j:=1 to k do
begin
time:=gettime(j*2-1,lsnnmb);
while (not pdtimeclass(time,classid1,classid2,classid3,classid4)) or (not pdtimeteacher(time,teacherid)) do
time:=getnexttime(time,lsnnmb);
classroomid:=getclassroom(mltnmb,typt);
while not (pdtimeclassroom(time,classroomid)) do
classroomid:=getnextclassroom(classroomid,typt);
while not (pdtimeclassroom(time,classroomid)) do
begin
time:=getnexttime(time,lsnnmb);
while (not pdtimeclass(time,classid1,classid2,classid3,classid4)) or (not pdtimeteacher(time,teacherid)) do
time:=getnexttime(time,lsnnmb);
classroomid:=getclassroom(mltnmb,typt);
while not (pdtimeclassroom(time,classroomid)) do
classroomid:=getnextclassroom(classroomid,typt);
end;
datamodule2.adoqueryinsert.Parameters.ParamByName('time').Value:=time;
datamodule2.adoqueryinsert.Parameters.ParamByName('classroomid').Value:=classroomid;
datamodule2.adoqueryinsert.ExecSQL;
end;
datamodule2.adodatasetlsntsk.Next;
end;
datamodule2.ADODataSetlsntsk.close;
end;
end;
程序在 typt:=datamodule2.ADODataSetlsntsk.fieldbyname('typt').value;处出错,提示为
:invalid variant type conversion.
请问这是何故?该怎么办?