vb调用存储过程 在对应所需名称或序数的集合中,未找到项目
Option ExplicitPublic LoginSucceeded As Boolean
Dim sql As String
Dim constr As String
Dim strS As String
Dim adoconn As New ADODB.Connection
Dim adocomm As New ADODB.Command
Dim rs As ADODB.Recordset
Dim prm1 As ADODB.Parameter
Dim prm2 As ADODB.Parameter
Dim prm3 As ADODB.Parameter
Dim prm4 As ADODB.Parameter
Dim ReturnValue As Integer
Dim UserCode As String
Dim Password As String
Dim OutUserName As String
Dim Outin_station As String
Private Sub cmdCancel_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
Me.Hide
End Sub
Private Sub cmdOK_Click()
UserCode = Trim(txtCode.Text)
Password = Trim(txtPassword.Text)
If Len(UserCode) = 0 Then
MsgBox "用户名不能为空,请重新输入用户名!", vbOKOnly, "输入提示"
txtCode.SetFocus
Exit Sub
ElseIf Len(UserCode) > 5 Then
MsgBox "用户名长度超过限制,请检查确认!", vbOKOnly, "输入提示"
txtCode.SetFocus
Exit Sub
ElseIf Len(Password) = 0 Then
MsgBox "密码不能为空,请重新输入密码!", vbOKOnly, "输入提示"
txtPassword.SetFocus
Exit Sub
ElseIf Len(Password) > 50 Then
MsgBox "密码长度超过限制,请检查确认!", vbOKOnly, "输入提示"
txtPassword.SetFocus
Exit Sub
End If
constr = "Provider=SQLOLEDB.1;Persist Security Info=True;User Id=sa;Password=;Initial Catalog=Gsqsy;Data Source=192.168.1.192"
Adodc1.ConnectionString = constr
adoconn.ConnectionString = Adodc1.ConnectionString
adoconn.Open
Set adocomm.ActiveConnection = adoconn
adocomm.CommandText = "Get_operator"
adocomm.CommandType = adCmdStoredProc
Set prm1 = adocomm.CreateParameter("@Czy_code", adVarChar, adParamInput, 5)
Set prm2 = adocomm.CreateParameter("@Czy_password", adVarChar, adParamInput, 50)
Set prm3 = adocomm.CreateParameter("@Czy_name", adVarChar, adParamOutput, 10)
Set prm4 = adocomm.CreateParameter("@Czy_in_station", adVarChar, adParamOutput, 4)
adocomm.Parameters.Append prm1
adocomm.Parameters.Append prm2
adocomm.Parameters.Append prm3
adocomm.Parameters.Append prm4
adocomm.Parameters.Refresh
prm1.Value = UserCode
prm2.Value = Password
Set rs = adocomm.Execute
ReturnValue = adocomm.Parameters(0)
a = adocomm.Parameters(1)
b = adocomm.Parameters(2)
Set rs = rs.NextRecordset
OutUserName = adocomm.Parameters(3)======================》这个地方报错
' If IsNull(adocomm.Parameters("@Czy_name").Value) Then
' OutUserName = ""
' MsgBox "该用户在数据库中不存在!或者密码错误!", vbOKOnly, "错误提示"
' Else
OutUserName = Trim(adocomm.Parameters("@Czy_name").Value)
Outin_station = Trim(adocomm.Parameters("@Czy_in_station").Value)
adoconn.Close
Set adoconn = Nothing
Unload frmLogin
MainFrm.Show
MsgBox "密码错误!请重新输入!", vbOKOnly, "密码错误!"
'
' End If
End Sub
对应的存储过程为:
CREATE procedure Get_operator
@Czy_code varchar(5),
@Czy_password varchar(50)
as
declare @Czy_name varchar(10)
declare @Czy_in_station varchar(4)
begin transaction
select @Czy_code=code,@Czy_password=password,@Czy_name=name,@Czy_in_station=in_station
from [User] where code = @Czy_code and password = @Czy_password
commit
select @Czy_code,@Czy_password,@Czy_name,@Czy_in_station
GO
--------------------编程问答-------------------- ReturnValue = adocomm.Parameters(0)
a = adocomm.Parameters(1)
b = adocomm.Parameters(2)
Set rs = rs.NextRecordset
OutUserName = adocomm.Parameters(3)======================》这个地方报错
' If IsNull(adocomm.Parameters("@Czy_name").Value) Then
' OutUserName = ""
' MsgBox "该用户在数据库中不存在!或者密码错误!", vbOKOnly, "错误提示"
' Else
这里面的a\b是随便加入的,不用考虑它们的问题。 --------------------编程问答-------------------- 有哪位高手能回答啊~难度太大了~ --------------------编程问答-------------------- 哪位高手帮我看看啊~
补充:VB , 数据库(包含打印,安装,报表)