存储过程 又不起作用 在线等!!
存储过程:
CREATE proc chklogin(@name nvarchar(20),@pwd nvarchar(40),@return bit output)
as
if (select count(*) from [admin] where username=@name and pwd=@pwd)> 0
begin
update [admin] set [lastlogintime]=getdate() where [username]=@name
set @return=0
end
else
set @return=1
GO
代码:
Dim con As SqlConnection = DB.con()
con.Open()
Dim cmd As SqlCommand = New SqlCommand( "chklogin ", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New SqlParameter( "@name ", SqlDbType.NVarChar, 20))
cmd.Parameters( "@name ").Value = txtname
cmd.Parameters.Add(New SqlParameter( "@pwd ", SqlDbType.NVarChar, 40))
cmd.Parameters( "@pwd ").Value = txtpwd
cmd.Parameters.Add(New SqlParameter( "@return ", SqlDbType.Bit))
If cmd.Parameters.Item( "@return ").Value = 0 Then
Return True
Else
Return False
End If
cmd.ExecuteNonQuery()
con.Close()
执行是可以 但是登陆以后不能修改用户登陆时间......
------解决方案--------------------CREATE proc chklogin(@name nvarchar(20),@pwd nvarchar(40),@return bit output)
as
if(exists(select top 1 username from [admin] where username=@name and pwd=@pwd))
begin
update [admin] set [lastlogintime]=getdate() where [username]=@name
set @return=0
end
else
begin
set @return=1
end
------解决方案--------------------cmd.Parameters.Add(New SqlParameter( "@return ", SqlDbType.Bit,System.Data.ParameterDirection.Output))
這樣應該是對的,因為你都沒有指定這個函數是返回值。
------解决方案-------------------- cmd.Parameters.Add(New SqlParamete