procedure TForm_logo.Button1Click(Sender: TObject);
begin
with Data_control.adoStoredProc1 do
begin
Close;
ProcedureName:='xueji_check;1';
Prepared:=true;
Parameters.Refresh; Parameters.ParamValues['@user_name']:= edit1.Text; if RaB_stu.Checked then
Parameters.ParamValues['@authority']:= 1
else if RaB_academy.Checked then
Parameters.ParamValues['@authority']:= 2
else
Parameters.ParamValues['@authority']:= 3; ExecProc;
if Parameters.ParamValues['@RETURN_VALUE'] = '1' then
Form3.Show
else
MessageBox(Handle, '用户名,密码或权限错误', '提示', MB_OK);
end;
end;第一次点击button可以正确执行,但是第二次就会出错。。为什么啊??
begin
with Data_control.adoStoredProc1 do
begin
Close;
ProcedureName:='xueji_check;1';
Prepared:=true;
Parameters.Refresh; Parameters.ParamValues['@user_name']:= edit1.Text; if RaB_stu.Checked then
Parameters.ParamValues['@authority']:= 1
else if RaB_academy.Checked then
Parameters.ParamValues['@authority']:= 2
else
Parameters.ParamValues['@authority']:= 3; ExecProc;
if Parameters.ParamValues['@RETURN_VALUE'] = '1' then
Form3.Show
else
MessageBox(Handle, '用户名,密码或权限错误', '提示', MB_OK);
end;
end;第一次点击button可以正确执行,但是第二次就会出错。。为什么啊??
Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 4DE433E4 in module 'sqloledb.dll'.Read of address 00000018'.Process stopped.Use Step orRun to continue.
跟踪调试一下
这是调用的存储过程:
CREATE PROCEDURE xueji_check@user_name varchar(50),
@authority varchar(10)ASdeclare @abc int
select @abc=count(*) from xj_user
where username=@user_name and authority=@authority
return @abc
GO
在控件里设也存储过程名,
代码里面 Parameters.Refresh;把这句取消,就不会有错了
还有更好的方法可以解决吗?
前面加句
Parameters.Clear;