I have a sqlserver with asp.net.I have a stored procedure in the database
named Try_Login
CREATE procedure dbo.Try_Login
(
@.LoginName nvarchar(15),
@.Password NvarChar(15)
)
as
select
UserName,
UserPassword,
UserClinic,
UserTester
from
Clinic_users
where
UserName = @.LoginName
and
UserPassword = @.Password
What I need to know is how to get my code to correspond with it.I.E. I have a login in form...
txtUsername and txtPassword need to be passed to this Stored procedure.
I assume you use .value to obtain thier values.Here is my code so far.....
Public Sub LoginDB()
Dim conLogin As SqlConnection
Dim cmdLogin As SqlCommand
Dim dtrLogin As SqlDataReader
conLogin = New SqlConnection("Server=myserver;database=APPOINTMENTS;uid=webtest;pwd=webtest")
cmdLogin = New SqlCommand("Try_Login ", txtUsername.Value, txtPassword.Value, conLogin)
cmdLogin.CommandType = CommandType.StoredProcedure
dtrLogin = cmdLogin.ExecuteReader()
While dtrLogin.Read()
End While
End Sub
I have no clue why it does not work........You need to add parameters:
cmdLogin = New SqlCommand("Try_Login ", conLogin)cmdLogin.CommandType = CommandType.StoredProcedure
cmd.Login.Parameters.Add("@.LoginName",txtUsername.Text)
cmd.Login.Parameters.Add("@.Password",txtPassword.Text)dtrLogin = cmdLogin.ExecuteReader()
While dtrLogin.Read()End While
No comments:
Post a Comment