|
code show as below:
SqlCommand cmd = new SqlCommand ("UsmgcfoxsExict", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add (new SqlParameter ("@ Uid", SqlDbType.Binary, 30));
cmd.Parameters ["@ Uid"]. Value = Encoding.UTF32.GetBytes (paraUid);
cmd.Parameters.Add (new SqlParameter ("@ UserName", SqlDbType.Binary, 30));
cmd.Parameters ["@ UserName"]. Direction = ParameterDirection.Output;
conn.Open ();
cmd.ExecuteNonQuery ();
conn.Close ();
I want to get the value of the parameter "@UserName" in cmd and convert it to string type. The parameter "@UserName" is binary type.
use:
byte [] b = cmd.Parameters ["@ UserName"]. value;
string sUserName = Encoding.UTF32.GetString (b);
But I get the following error:
Error 1 Cannot implicitly convert type "object" to "byte []". There is an explicit conversion (is a cast missing?) |
|