R
Rudy
Hello all!
I'm working with the following code..
Function DBAuthenticate(ByVal strUsername As String, ByVal strPassword As
String) As Integer
Dim conLogin As SqlConnection
Dim cmdSelect As SqlCommand
Dim parmReturnValue As SqlParameter
Dim intResult As Integer
conLogin = New
SqlConnection("Server=localhost;UID=**;PWD=**;Database=sample")
cmdSelect = New SqlCommand("DBAuthenticate", conLogin)
cmdSelect.CommandType = CommandType.StoredProcedure
parmReturnValue = cmdSelect.Parameters.Add("RETURN_VALUE",
SqlDbType.Int)
parmReturnValue.Direction = ParameterDirection.ReturnValue
cmdSelect.Parameters.Add("@username", strUsername)
cmdSelect.Parameters.Add("@password", strPassword)
'Encrypt the password
Dim md5Hasher As New MD5CryptoServiceProvider
Dim hashedDataBytes As Byte
Dim encoder As New UTF8Encoding
hashedDataBytes = md5Hasher.ComputeHash(encoder.GetBytes(strPassword))
Dim paramPwd As SqlParameter
paramPwd = New SqlParameter("@password", SqlDbType.Binary, 16)
paramPwd.Value = hashedDataBytes
cmdSelect.Parameters.Add(paramPwd)
conLogin.Open()
cmdSelect.ExecuteNonQuery()
intResult = cmdSelect.Parameters("RETURN_VALUE").Value
conLogin.Close()
If intResult < 0 Then
If intResult = -1 Then
lblMessage.Text = "This guest is not registered."
Else
lblMessage.Text = "Sorry, invalid password."
End If
End If
Return intResult
End Function
with this line " hashedDataBytes =
md5Hasher.ComputeHash(encoder.GetBytes(strPassword))" I am geting the
following error
'Public Overrides Function GetBytes(s As String) As Byte()': Value of
type 'System.Web.UI.WebControls.TextBox' cannot be converted to 'String'.
Any thoughts?
Rudy
I'm working with the following code..
Function DBAuthenticate(ByVal strUsername As String, ByVal strPassword As
String) As Integer
Dim conLogin As SqlConnection
Dim cmdSelect As SqlCommand
Dim parmReturnValue As SqlParameter
Dim intResult As Integer
conLogin = New
SqlConnection("Server=localhost;UID=**;PWD=**;Database=sample")
cmdSelect = New SqlCommand("DBAuthenticate", conLogin)
cmdSelect.CommandType = CommandType.StoredProcedure
parmReturnValue = cmdSelect.Parameters.Add("RETURN_VALUE",
SqlDbType.Int)
parmReturnValue.Direction = ParameterDirection.ReturnValue
cmdSelect.Parameters.Add("@username", strUsername)
cmdSelect.Parameters.Add("@password", strPassword)
'Encrypt the password
Dim md5Hasher As New MD5CryptoServiceProvider
Dim hashedDataBytes As Byte
Dim encoder As New UTF8Encoding
hashedDataBytes = md5Hasher.ComputeHash(encoder.GetBytes(strPassword))
Dim paramPwd As SqlParameter
paramPwd = New SqlParameter("@password", SqlDbType.Binary, 16)
paramPwd.Value = hashedDataBytes
cmdSelect.Parameters.Add(paramPwd)
conLogin.Open()
cmdSelect.ExecuteNonQuery()
intResult = cmdSelect.Parameters("RETURN_VALUE").Value
conLogin.Close()
If intResult < 0 Then
If intResult = -1 Then
lblMessage.Text = "This guest is not registered."
Else
lblMessage.Text = "Sorry, invalid password."
End If
End If
Return intResult
End Function
with this line " hashedDataBytes =
md5Hasher.ComputeHash(encoder.GetBytes(strPassword))" I am geting the
following error
'Public Overrides Function GetBytes(s As String) As Byte()': Value of
type 'System.Web.UI.WebControls.TextBox' cannot be converted to 'String'.
Any thoughts?
Rudy