Hi! I´m new to VB but and i´m having the following problem.
I´ve created a website application with two text boxes a label and a button. The click event of the button "calls" a sql server 2008 stored procedure that has two inputs (textbox1 and textbox2) ans one output that is shown in label1.
Thi is the VB code
Code:
Dim sqlconn As New SqlClient.SqlConnection
sqlconn.ConnectionString = "conn string"
sqlconn.Open()
Dim user As String
Dim pass As String
user = TxtName.Text
pass = TxtPass.Text
Dim sqlcmd As New SqlCommand
sqlcmd.Connection = sqlconn
sqlcmd.CommandType = CommandType.StoredProcedure
sqlcmd.CommandText = "ValidaUser"
sqlcmd.Parameters.Add("@user", SqlDbType.VarChar, ParameterDirection.Input).Value = user
sqlcmd.Parameters.Add("@pass", SqlDbType.VarChar, ParameterDirection.Input).Value = pass
sqlcmd.Parameters.Add("@valor", SqlDbType.Int)
sqlcmd.Parameters("@valor").Direction = ParameterDirection.Output
sqlcmd.ExecuteNonQuery()
lblLogin.Text = sqlcmd.Parameters("@valor").Value.ToString()
sqlconn.Close()
This is the SP
Code:
ALTER procedure [dbo].[ValidaUser] (@user varchar (10),@pass varchar(8),@valor int output)
as
set @valor =
(
select count(UserId)
from Users
where UserId = @user
and UserPass = @pass
)
The purpose is that if the user and password exist the label shows 1 if it does not exists the label shows 0.
But i´m getting the following behavior;