|
发表于 2020-4-26 22:30:02
|
显示全部楼层
那为什么我将字段改成char型时又有返回值呢?
数据库:
CREATE procedure UsmgcfoxsExict
@Uid binary(30),
@UserName binary(30) output
as
select @UserName=UserName from AlbumLogin where Uid=@Uid
GO
程序:
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) );
错误:
无法将类型为“System.DBNull”的对象强制转换为类型“System.Byte[]” |
|