probelaw
asked on
CreateParameter with varbinary
I am trying to create queries to store a MD5 encoded password in SQL server field with datatype varbinary(50)
I get the error "Application uses a value of the wrong type for the current operation. "
Below is the code. What's going wrong??
<%
Set cmdSetPassword = Server.CreateObject ("ADODB.Command")
cmdSetPassword.ActiveConne ction = MM_sqldb_STRING
cmdSetPassword.CommandText = "UPDATE Users SET Password = ? WHERE Username = ?"
cmdSetPassword.Parameters. Append cmdSetPassword.CreateParam eter("varP assword", 204, 1, 50, MM_IIF(varPassword, varPassword, cmdSetPassword__varPasswor d & ""))
cmdSetPassword.Parameters. Append cmdSetPassword.CreateParam eter("varU sername", 200, 1, 50, MM_IIF(varUsername, varUsername, cmdSetPassword__varUsernam e & ""))
cmdSetPassword.CommandType = 1
cmdSetPassword.CommandTime out = 0
cmdSetPassword.Prepared = true
cmdSetPassword.Execute()
%>
I get the error "Application uses a value of the wrong type for the current operation. "
Below is the code. What's going wrong??
<%
Set cmdSetPassword = Server.CreateObject ("ADODB.Command")
cmdSetPassword.ActiveConne
cmdSetPassword.CommandText
cmdSetPassword.Parameters.
cmdSetPassword.Parameters.
cmdSetPassword.CommandType
cmdSetPassword.CommandTime
cmdSetPassword.Prepared = true
cmdSetPassword.Execute()
%>
ASKER
At the moment I believe it is just a binary value resulting from the MD5 function
i.e....
varPassword = MD5(Password)
Should it be declared a specific way?
i.e....
varPassword = MD5(Password)
Should it be declared a specific way?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Changing the datatype in the database to varchar and the parameter to the same works well. Is there any big difference or risk to doing it this way?
Thanks for the help.
Thanks for the help.
No.
Any reason to use varbinary? Why not use varchar?
What is the data type for the value you are assigning to the password?