完整的程序如下
<%Dim strUserName
Dim strPassword
Dim strUserID
Dim objSecurity
Response.Cookies("userauthid")= ""strUserName = Request.Form("txtUserName")
strPassword = Request.Form("txtPassword")strUserID = GetUserID(strUserName, strPassword)If strUserID= "invalid" Then
Response.Write "<H2>登录确认错误</H2>"
Response.Write "请再试一次."
Server.transfer "login.htm"
Else
Response.Cookies("userauthid")= strUserID
server.execute "main.asp"
End If
Function GetUserID(strUserName, strPassword)
Dim cmd
Dim conDB
Dim strUserID
Dim Rs
strUserID = "invalid"
If ValidData(strUserName, strPassword) Then
Set cmd = CreateObject("ADODB.Command")
With cmd
.ActiveConnection = strCon
.CommandText = "GetUserID"
.CommandType = adCmdStoredProc
.Parameters(1).Value = strUserName
.Parameters(2).Value = strPassword
End With If Not IsNull(cmd.Parameters(3).Value) Then
strUserID = cmd.Parameters(3).Value
End If
End If
GetUserID = strUserID
Set cmd = Nothing
End Function
%>
<%Dim strUserName
Dim strPassword
Dim strUserID
Dim objSecurity
Response.Cookies("userauthid")= ""strUserName = Request.Form("txtUserName")
strPassword = Request.Form("txtPassword")strUserID = GetUserID(strUserName, strPassword)If strUserID= "invalid" Then
Response.Write "<H2>登录确认错误</H2>"
Response.Write "请再试一次."
Server.transfer "login.htm"
Else
Response.Cookies("userauthid")= strUserID
server.execute "main.asp"
End If
Function GetUserID(strUserName, strPassword)
Dim cmd
Dim conDB
Dim strUserID
Dim Rs
strUserID = "invalid"
If ValidData(strUserName, strPassword) Then
Set cmd = CreateObject("ADODB.Command")
With cmd
.ActiveConnection = strCon
.CommandText = "GetUserID"
.CommandType = adCmdStoredProc
.Parameters(1).Value = strUserName
.Parameters(2).Value = strPassword
End With If Not IsNull(cmd.Parameters(3).Value) Then
strUserID = cmd.Parameters(3).Value
End If
End If
GetUserID = strUserID
Set cmd = Nothing
End Function
%>
.Parameters(1).Value = strUserName
Dim adoCmd As New ADODB.Command
Dim adoRs As New ADODB.Recordset
adoCnn.Open "dsn=stk;uid=callcntr;pwd=callcntr"
Set fundacc = adoCmd.CreateParameter("@fundacc", adChar, adParamInput, 20, "075512568376")
adoCmd.Parameters.Append fundacc
Set xname = adoCmd.CreateParameter("@name", adChar, adParamInput, 10, "")
adoCmd.Parameters.Append xname
Set area = adoCmd.CreateParameter("@area", adChar, adParamInput, 4, "")
adoCmd.Parameters.Append area
Set res = adoCmd.CreateParameter("@HandleResult", adChar, adParamOutput, 8)
adoCmd.Parameters.Append res
adoCmd.CommandText = "pc_stQryCustomerInfo"
adoCmd.CommandType = adCmdStoredProc
adoCmd.ActiveConnection = adoCnn
Set adoRs = adoCmd.Execute
...... Rs1.Close
Set Rs1 = Nothing
你得先建立vb的参数对象,然后才给参数对像赋值。像这样:
Dim pra
With cmd
.ActiveConnection = strCon
.CommandText = "getuserid"
.CommandType = adCmdStoredProc
SET pra=.CreateParameter("@P1", adChar, adParamInput, 20, "")
pra.Value=strUserName
.Parameters.Append pra
Set pra=.CreateParameter("@P2", adChar, adParamInput, 20, "")
pra.Value=strPassword
.Parameters.Append pra
......
End With
即 command的parameters集合为空。 它为空,下标为1的parameter就不存在,又如何赋值? 赋值操作又如何不报错?
cmd.parameters.add(......)
cmd.parameters.add(......)
cmd.parameters(1).value = ...
学数据库和ASP都是半吊子,做起东西来真是好累啊