我在数据库中建过程
create proc pro_dishopeid(@ret int output)
as
begin
  declare @max int
  select @max=max(kc_id) from tb_kcxx
  if @max is null
    set @max=1
  else
    set @max=@max+1
end VB 中代码调用如下Private Sub Command1_Click()
  
  Dim dicmd As New ADODB.command
  
  With dicmd
    .ActiveConnection = cn
    .CommandType = adCmdStoredProc
    .CommandText = "pro_dishopeid"
  End With
  
  Dim res As New ADODB.Parameter
  With res
    .direction = adParamOutput
    .Type = adVarChar
    .Size = 60
  End With  dicmd.Parameters.Append res
  
  dicmd.Execute
   
   Text1.Text = res.Value
   
End Sub但运行时报错     无效使用NULL    不知那地方错了, 各位大哥大姐快帮帮忙!

解决方案 »

  1.   

    Text1.Text = res.Value是不是这一行报错,你这里并没有说明text1的记录要赋值给数据库的那个字段
      

  2.   

    Text1.Text = res.Value & ""
      

  3.   

    不知道什么数据库,没看到return类似的。
      

  4.   

    Text1.Text = iif(isnull(res.Value),"",res.Value)
      

  5.   

    Text1.Text = res.Value & 
      

  6.   

    存储过程带参数,调用时没有传参报错
    @ret参数没有用到,去掉即可
      

  7.   

    存储过程有问题,你是不是要返回@max的值给输出参数,但没有返回语句,添加上就可以解决null的问题。