|
So why do I have a return value when I change the field to char type?
database:
CREATE procedure UsmgcfoxsExict
@Uid binary (30),
@UserName binary (30) output
as
select @ UserName = UserName from AlbumLogin where Uid = @ Uid
GO
program:
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 ();
return Encoding.UTF32.GetString (((byte []) cmd.Parameters ["@ UserName"]. Value));
error:
Unable to cast object of type "System.DBNull" to type "System.Byte []" |
|