if y=0 then begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Select TypeID From Type Where TypeName=''填空题''');
ADOQuery1.Open;
temp:=ADOQuery1.FieldValues['TypeID'];
ADOQuery2.Close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('Select BH From NYD Where NYD=:NY');
ADOQuery2.Parameters.ParamByName('NY').Value:=NY_ComboBox2.Text;
ADOQuery2.Open;
temp1:=ADOQuery2.FieldValues['BH'];
procedure TTIMuLuRu.LR_Button2Click(Sender: TObject);
type
SZ=array[1..5]of string;
var
temp,x,i,y:integer;
temp1,temp2:string;
SZx:SZ;
begin
y:=0;
i:=1;
SZx[1]:='';
if TM_Edit2.Text='' then ShowMessage('题目不能为空')
else if NY_ComboBox2.Text='' then ShowMessage('难易度不能为空')
else if ZJ_ComboBox2.Text='' then ShowMessage('所在章节不能为空')
else if Kong_ComboBox.Text='' then ShowMessage('空数不能为空')
else begin
temp:=StrToInt(Kong_ComboBox.Text);
SZx[1]:=Kong_Edit1.Text;
SZx[2]:=Kong_Edit2.Text;
SZx[3]:=Kong_Edit3.Text;
SZx[4]:=Kong_Edit4.Text;
SZx[5]:=Kong_Edit5.Text;
for x:=1 To temp do
begin
i:=x;
if SZx[i]='' then break;
end;
end;
if SZx[i]='' then ShowMessage('您少输入了应填空的答案')
else begin
temp1:=TM_Edit2.Text;
ADOQuery2.Close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('SELECT TM FROM TianKong');
ADOQuery2.Open;
While not ADOQuery2.Eof do
begin
temp2:=ADOQuery2.FieldValues['TM'];
if temp1=temp2 then begin
y:=1;
break;
end;
ADOQuery2.Next;
end;
if y=0 then begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Select TypeID From Type Where TypeName=''填空题''');
ADOQuery1.Open;
temp:=ADOQuery1.FieldValues['TypeID'];
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('INSERT INTO TianKong(TypeID,TM,K1,K2,K3,K4,K5,YTS,NY,CZ) VALUES(:temp,:TM,:K1,:K2,:K3,:K4,:K5,:YTS,:NY,:CZ)');
ADOQuery1.Parameters.ParamByName('temp').Value:=temp;
ADOQuery1.Parameters.ParamByName('TM').Value:=TM_Edit2.Text;
ADOQuery1.Parameters.ParamByName('K1').Value:=Kong_Edit1.Text;
ADOQuery1.Parameters.ParamByName('K2').Value:=Kong_Edit2.Text;
ADOQuery1.Parameters.ParamByName('K3').Value:=Kong_Edit3.Text;
ADOQuery1.Parameters.ParamByName('K4').Value:=Kong_Edit4.Text;
ADOQuery1.Parameters.ParamByName('K5').Value:=Kong_Edit5.Text;
ADOQuery1.Parameters.ParamByName('YTS').Value:=StrToInt(Kong_ComboBox.Text);
ADOQuery2.Close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('Select BH From NYD Where NYD=:NY');
ADOQuery2.Parameters.ParamByName('NY').Value:=NY_ComboBox2.Text;
ADOQuery2.Open;
temp:=ADOQuery2.FieldValues['BH'];
ADOQuery1.Parameters.ParamByName('NY').Value:=temp;
ADOQuery1.Parameters.ParamByName('CZ').Value:=ZJ_ComboBox2.Text;
ADOQuery1.ExecSQL;
!!!!!!ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Select 1 From TianKong');
ADOQuery1.Open;
TH_Edit2.Text:=IntToStr(ADOQuery1.RecordCount+1);
TM_Edit2.Clear;
Kong_Edit1.Clear;
Kong_Edit2.Clear;
Kong_Edit3.Clear;
Kong_Edit4.Clear;
Kong_Edit5.Clear;
end
else showmessage('此题已经存在!');
end;
end;
加感叹号的就是运行时报错停的地方