티스토리 뷰

WPF

MSSQL HashBytes Sqlparameter Error

NicSub 2022. 6. 30. 19:12
728x90
반응형

 

MSSQL HashBytes Sqlparameter Type Error

Parameter Type Varchar != Nvarchar  HashBytes different binary value 

-->>

Sovled 1.
 var _pWDs = new SqlParameter("@PWDs",  SqlDbType.VarChar,500);
_pWDs.Value = Ubody.PWD2;

// Query String
comm.CommandText += " select * from UidTable where password = Hashbyte('SHA2_256',@PWDs);

comm.Parameters.Add(_pWDs);

Solved 2.

comm.CommandText += " select * from UidTable where password = Hashbyte('SHA2_256',@PWDs);
comm.Parameters.Add("@PWDs",SqlDbType.VarChar,500);
comm.Parameters["@PWDs"].Value = Ubody.PWD2

Solved 3.

  var _pWDs = new SqlParameter("@PWDs");
comm.CommandText = "DECLARE @PWD2 VARCHAR(500); Set @PWD2 =@PWDs";
comm.CommandText += " select * from UidTable where password = Hashbyte('SHA2_256',@PWD2 );
comm.Parameters.Add(_pWDs);

 

 

 

c# - Why does SqlCommand not pass parameter inside a HASHBYTES function? - Stack Overflow

반응형
댓글