Results 1 to 1 of 1

Thread: Problem with simple login(please delete duplicated post)

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2014
    Posts
    11

    Problem with simple login(please delete duplicated post)

    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;

    Name:  a.jpg
Views: 261
Size:  18.6 KB
    Last edited by DayaWulf; Apr 11th, 2014 at 08:56 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width