procedure TForm1.Button2Click(Sender: TObject);
begin
if edit1.Text ='' then
begin
showmessage('请输入要查询的图书号!');
exit;
end;
ado2.Close;
ado2.SQL.Clear;
ado2.SQL.add('select BookID from Book_Info where BookID='''+edit1.Text+'''');
ado2.Open;
if ado2.RecordCount <=0 then
begin
showmessage('该图书号不存在!');
exit;
end;
try
DBGrid1.Refresh;
ado2.Close;
ado2.SQL.Clear;
ado2.SQL.add('Select from Book_Info where BookID='''+edit1.Text+'''');
ado2.open;
DBGrid1.Refresh;
ado2.Close;
ado2.SQL.Clear;
ado2.SQL.add('Select from Book_Info where BookID='''+edit1.Text+'''');
ado2.open;
except
showmessage('查询时出现错误,请核对数据是否正确!');
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;end.
错误提示是SELECT语句问题或标点问题,或者是保留字问题.....
begin
if edit1.Text ='' then
begin
showmessage('请输入要查询的图书号!');
exit;
end;
ado2.Close;
ado2.SQL.Clear;
ado2.SQL.add('select BookID from Book_Info where BookID='''+edit1.Text+'''');
ado2.Open;
if ado2.RecordCount <=0 then
begin
showmessage('该图书号不存在!');
exit;
end;
try
DBGrid1.Refresh;
ado2.Close;
ado2.SQL.Clear;
ado2.SQL.add('Select from Book_Info where BookID='''+edit1.Text+'''');
ado2.open;
DBGrid1.Refresh;
ado2.Close;
ado2.SQL.Clear;
ado2.SQL.add('Select from Book_Info where BookID='''+edit1.Text+'''');
ado2.open;
except
showmessage('查询时出现错误,请核对数据是否正确!');
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;end.
错误提示是SELECT语句问题或标点问题,或者是保留字问题.....
try
DBGrid1.Refresh;
ado2.Close;
ado2.SQL.Clear;
ado2.SQL.add('Select * from Book_Info where BookID='''+edit1.Text+'''');//原来没字段参数
ado2.open;
DBGrid1.Refresh;
//为什么要重复下面的语句?
// ado2.Close;
// ado2.SQL.Clear;
// ado2.SQL.add('Select from Book_Info where BookID='''+edit1.Text+'''');
// ado2.open;
except
showmessage('查询时出现错误,请核对数据是否正确!');
end;
......