|
database:
CREATE procedure UserIsExict
@Uid binary (30),
@UserName binary (30) output
as
select @ UserName = UserName from AlbumLogin where Uid = @ Uid
GO
program:
SqlCommand cmd = new SqlCommand ("UserIsExict", 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:
Cannot cast an object of type "System.DBNull" to type "System.Byte []" |
|