if Query.RecordCount = 0 then
ShowMsg('登录失败,请检查一下用户名和密码是否正确!')
else
ShowMsg('登录成功!');本人菜鸟,在做用户登录界面时,用到SQLQuery,在对用户名、密码和Oracle9i中的资料进行核查时,报错:表或视图不存在。数据库连接无问题。经过在网上搜索,说是此处写法不对,但不知道如何修正。我只在登录界面用了一个SQLQuery组件,其SQLConnection属性是uses另一个DataModule中的SQLConnection。请各位指点一下,谢谢!
ShowMsg('登录失败,请检查一下用户名和密码是否正确!')
else
ShowMsg('登录成功!');本人菜鸟,在做用户登录界面时,用到SQLQuery,在对用户名、密码和Oracle9i中的资料进行核查时,报错:表或视图不存在。数据库连接无问题。经过在网上搜索,说是此处写法不对,但不知道如何修正。我只在登录界面用了一个SQLQuery组件,其SQLConnection属性是uses另一个DataModule中的SQLConnection。请各位指点一下,谢谢!
begin
if Query.RecordCount = 0 then
ShowMsg('登录失败,请检查一下用户名和密码是否正确!')
else
ShowMsg('登录成功!');
end
else
begin
ShowMsg('数据库连接失败!');
end;
使用Query.RecordCount = 0报错(和最初报错内容相同),报错内容如下Project SoftManager.exe raised exception class EDatabaseError with message 'SQLServer Error: ORA-00942: 表或视图不存在'.Process stopped.Use Step or Run to continue.
其中SoftManager.exe是我的工程名。源码如下:
PUser := UpperCase(edtLander.Text);
PPwd := edtPwd.Text;
PPwd := Encrypt(PPwd);
Str := 'select * from sm_inf_lander where upper(landercode)=''' + PUser + ''' '
+ 'and password=''' + PPwd + '''';
Query.Close;
Query.SQL.Text := Str;
Query.Open;
if Query.RecordCount > 0 then
//if Query.IsEmpty then
//if Query.Eof then
//ShowMsg('登录失败,请检查一下用户名和密码是否正确!')
ShowMsg('登录成功!')
else
//ShowMsg('登录成功!');
ShowMsg('登录失败,请检查一下用户名和密码是否正确!');
end;
因为是用dbExpress连接oracle数据库,所以不用ADOQuery。
网上有人说可能是SQLQuery的BUG,用SQLQuery+DataSetProvider+ClientDataSet可以解决,但我不知道具体怎么操作。我用的是Delphi7.0,已打过所有补丁。
PPwd := edtPwd.Text;
PPwd := Encrypt(PPwd);
Str := 'select count(*) from sm_inf_lander where upper(landercode)=''' + PUser + ''' '
+ 'and password=''' + PPwd + '''';
Query.Close;
Query.SQL.Text := Str;
Query.Open;
if Query.Fields[0].asInteger > 0 then
//if Query.IsEmpty then
//if Query.Eof then
//ShowMsg('登录失败,请检查一下用户名和密码是否正确!')
ShowMsg('登录成功!')
else
//ShowMsg('登录成功!');
ShowMsg('登录失败,请检查一下用户名和密码是否正确!');
end;
表名没有问题,在查询分析器有返回结果。larruping(诸相非相) :
if Query.Fields[0].asInteger > 0 then报错:Query:Operation not allowed on a unidirectional dataset.
不允许单向数据集。
刚才我搞错了,if Query.Fields[0].asInteger > 0 then报错:'' is not a valid integer value