Procedure TForm1. Btn1Click (Sender: TObject);
Var
I: Extended;
The begin
If MessageDlg (' to new information, please? ', mtInformation mbOKCancel, 0)=mrOk then begin
Qry1. Close;
Qry1. SQL. The Clear;
Qry1. SQL. The Add (' select * from tb_stu_practice where stu_no='" + edt2. Text + "' ");
Qry1. Open;
If qry1. RecordCount=1 then the begin
Showmessage (' have records of the same student id! Don't let it repeat new, use the save changes');
exit;
end;
With sp1 do begin
The Close;
ProcedureName:='sp_tb_add_stu';
The Parameters. Refresh;
If (edt2. Text=' ') or (edt1. Text=' ') or (edt8. Text=' ') then the begin
ShowMessage (' blue as required);
exit;
End the else begin
The Parameters. ParamByName (' @ stu_name). Value:=TrimLeft (edt1. Text);
If TryStrToFloat (Edt2. The Text, I) then the begin
The Parameters. ParamByName (' @ stu_no '). The value:=TrimLeft (edt2. Text);
End the else begin
ShowMessage (' should be numeric type);
The Exit;
end;
If TryStrToFloat (Edt8. The Text, I) then the begin
The Parameters. ParamByName (' @ stu_id) value:=TrimLeft (edt8. Text);
End the else begin
ShowMessage (' should be numeric type);
The Exit;
end;
end;
If edt4. Text<> 'then the begin
If (edt4. Text='female') or (edt4. Text='male') then
The Parameters. ParamByName (' @ stu_sex '). The value:=TrimLeft (edt4. Text)
The else begin
ShowMessage (' "male" or "female" empty ");
The Exit;
end;
End the else Parameters. ParamByName (' @ stu_sex). Value:=null;
If edt5. Text<> 'then the begin
If (TryStrToFloat (Edt5. The Text, I)) and (StrToInt (Edt5. Text) & gt;=1) and (STRTOINT (edt5. Text) & lt;=130) then
The Parameters. ParamByName (' @ stu_age '). The value:=TrimLeft (edt5. Text)
The else begin
ShowMessage (' between 1 to 130 Numbers or empty ');
The Exit;
end;
End the else Parameters. ParamByName (' @ stu_age). Value:=null;
If edt6. Text<> 'then the begin
If (TryStrToFloat (Edt6. The Text, I)) then
The Parameters. ParamByName (' @ les_id '). The value:=TrimLeft (edt6. Text)
The else begin
ShowMessage (' les_id for Numbers or null).
The Exit;
end;
End the else Parameters. ParamByName (' @ les_id). Value:=null;
If edt7. Text & lt;> "' then
The Parameters. ParamByName (' @ inclass '). The value:=TrimLeft (edt7. Text)
The else
The Parameters. ParamByName (' @ inclass '). The value:=null;
Prepared:=True;
ExecProc;
End
ShowMessage (' new 'success);
The end;
end;
CodePudding user response:
That the fault?CodePudding user response:
Debug it and see where the fault,CodePudding user response:
Pay attention to the refresh data setCodePudding user response:
Step by step, trace to the second click the new button, went straight to the end, the error is: the Access violation at address 4 de43404 module in 'sqloledb. DLL', the Read of because the address is 00000018 SP1 and qry1 Shared a datasource, or DBGRID not clear? Why use listview display canCodePudding user response: