I need to modify someone else's VB code, and I don't have much experience with VB6. I need to call a SQL2000 stored procedure using ADODB. One of the parameters is of type Binary and it's giving me problems. Every time I create the parameter, I get an error "Application uses a value of the wrong type for the current operation". The error happens at the cmd.parameter.append line, it doesn't even give me a chance call the cmd.execute.
Dim HexPassword As String
Dim BinPassword As String
Dim AsciiCode As Integer
Dim unitDigit As String
Dim TensDigit As String
Set obj_hash = New EDCrypt
' Returns Hash of password hex encoded
HexPassword = obj_hash.GetTextHash(Trim(txtPassword.text), haSHA1)
' Converts Hex Encoded string to Binary encoded string
Dim i As Integer
For i = 1 To 40 Step 2
unitDigit = Mid(HexPassword, i + 1, 1)
TensDigit = Mid(HexPassword, i, 1)
AsciiCode = HexStrtoInt(TensDigit + unitDigit)
BinPassword = BinPassword + Chr(AsciiCode)
Next i
conn.Open ConnectionString
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = conn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "ValidatePasswordNew"
cmd.Parameters.Append cmd.CreateParameter("LoginID", adVarChar, adParamInput, 30, UserID)
cmd.Parameters.Append cmd.CreateParameter("ShaPassword", adBinary, adParamInput, 20, BinPassword)