新手的问题:为什么有记录的时候却找不到记录??(50分)

  • 主题发起人 主题发起人 球迷
  • 开始时间 开始时间

球迷

Unregistered / Unconfirmed
GUEST, unregistred user!
各位大虾,我是一个DELPHI的新手,今后请多多指教!!
在查找table1当中的记录时,虽然table1中有记录,但却找不到,下面是那段程序,麻烦各位大虾看看我到底错在哪

unit Look_accDlg;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, StdCtrls;
type
Tlook_acc_input = class(TForm)
Label1: TLabel;
ComboBox1: TComboBox;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Query1: TQuery;
Table1: TTable;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
look_acc_input: Tlook_acc_input;

implementation

uses Look_accept, Main_case;

{$R *.dfm}

procedure Tlook_acc_input.Button1Click(Sender: TObject);
var accept_look:Taccept_look ;
tmp:string;
begin
accept_look:=Taccept_look.Create(self);
case ComboBox1.ItemIndex of
0:begin
Table1.Open;
Table1.SetKey;
// tmp:=table1.Fields[1].AsString;
// showmessage(tmp); //我用这个发现table1中无记录,但实际上有记录
Table1.FieldByName('accept_no').AsString:=Edit1.Text;
if not table1.GotoKey then showmessage('not find record');
end; // 受理编号
......
 
Table1.FieldByName('accept_no').AsString:=Edit1.Text;
if not table1.GotoKey then showmessage('not find record');
end; // 受理编号

// tmp:=table1.Fields[1].AsString;
// showmessage(tmp); //我用这个发现table1中无记录,但实际上有记录
这样应可以了吧
 
好象没有什么变化啊
你只是调了一下顺序
而我加上
// tmp:=table1.Fields[1].AsString;
// showmessage(tmp); //我用这个发现table1中无记录,但实际上有记录
只是为了调试而已
去掉还是找不到记录
这里面有没有系统环境方面的原因?
请诸位大虾救命啊!!
 
我不知道你的数据库是什么,我曾用过adoquery查询SQL SERVER 6.5的,也是查不到数据,
但实际有。后来换了低版本的mdac,就行了,
这是个思路,你再自己看看吧
 
我的数据库是PARADOX,通过BDE连
 
不好意思哪位大虾告诉我什么是MDAC?
 
我刚才又试了一下,程序显示记录存在,但对应的字段值为空(我用SQL explore查询字段值不为空)
而在该程序其它单元我用相似的代码就能找到记录,只是表名不一样,我现在真的不知道该怎么办了
是不是用paradox容易出现这种情况,还是我的table需要重建?
哪位大虾能帮帮我?救急啊!!!
 
接受答案了.
 
后退
顶部