各位大侠快来帮忙,两个返回值的问题
Public DBCnn As New ADODB.Connection '定义全局标量用于连接数据库
Public strCnn As String '连接字符串
Public cmd As ADODB.Command '命令
Public rs1 As ADODB.Recordset '检索医生或供货商
Public rstByQuery As ADODB.Recordset '结果集
Public param As ADODB.Parameter
'自动识别数据库路径
strCnn = "Driver={SQL server};server=FS;uid=sa;pwd=;database=yd"
DBCnn.Open strCnn
D = "update_kc_minus" & " " & Trim(jsr.Text) & "," & Trim(doctor.Text) & ""
Set rstByQuery = New ADODB.Recordset
Set cmd = New ADODB.Command
Set param = cmd.CreateParameter("RetVal", adInteger, adParamReturnValue, 4)
cmd.Parameters.Append param
Set rstByQuery = DBCnn.Execute(D)
Set rs1 = cmd.Execute() ----在这里提示“连接无法执行此操作,在此上下文中它可能已被关闭或无效”
Set rs1 = Nothing
If cmd.Parameters("RetVal").Value = 1 Then --这里是获得存储过程返回的RETURN值
MsgBox ("库存数量不足,请重新输入数量!!!")
Exit Sub
Else
lsph = rstByQuery("djh")
Set rstByQuery = Nothing
Text2.Text = lsph
End If
[解决办法]