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可以正确执行,但是第二次就会出错。。为什么啊??

解决方案 »

  1.   

    第二次点击按钮就会弹出对话框:
    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.
      

  2.   

    看起来象SQL错误
    跟踪调试一下
      

  3.   

    但是第一次都不会出错啊。。
    这是调用的存储过程:
    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
      

  4.   

    是有这问题....我碰到过的
    在控件里设也存储过程名,
    代码里面 Parameters.Refresh;把这句取消,就不会有错了
      

  5.   

    要不你执行完后把Prepared:=False;
      

  6.   

    还是不行啊,如果把Parameters.Refresh;取消,就会出现@user_name not found 的错误如果执行完后把Prepared:=False;还是会出现相同错误
      

  7.   

    我是说把存储过程名和参数全在那个ADOSTOREDPROC控件中设好,不象你这样动态的给。再去掉那一句
      

  8.   

    这样啊。。那不是很不方便。。一个ADOSTOREDPROC就只能对应一个存储过程了
    还有更好的方法可以解决吗?
      

  9.   

    如果非要动态的,可以试试在Parameters.Refresh;
    前面加句
    Parameters.Clear;